private void UpdateList()
        {
            LuaProfileResultsDocument doc = (LuaProfileResultsDocument)Document;

            profileListView.BeginUpdate();
            profileListView.Items.Clear();

            foreach (LuaProfileEntry entry in doc.Functions)
            {
                ListViewItem item = new ListViewItem(entry.m_function);
                item.Tag = entry;

                if (entry.m_line > 0)
                {
                    item.SubItems.Add(entry.m_file + ":" + entry.m_line);
                }
                else
                {
                    item.SubItems.Add(entry.m_file);
                }

                item.SubItems.Add(entry.m_language);

                if (m_displayMode == DisplayMode.Percentages)
                {
                    item.SubItems.Add(((double)entry.m_count / (double)m_totalCount).ToString("0.0000%"));
                    item.SubItems.Add((entry.m_timeSelf / m_totalTime).ToString("0.0000%"));
                    item.SubItems.Add((entry.m_timeChildren / m_totalTimeChildren).ToString("0.0000%"));
                    item.SubItems.Add(((entry.m_timeSelf + entry.m_timeChildren) / (m_totalTime + m_totalTimeChildren)).ToString("0.0000%"));
                }
                else if (m_displayMode == DisplayMode.Milliseconds)
                {
                    item.SubItems.Add(entry.m_count.ToString());
                    item.SubItems.Add((entry.m_timeSelf * 1000.0).ToString("0.00000"));
                    item.SubItems.Add((entry.m_timeChildren * 1000.0).ToString("0.00000"));
                    item.SubItems.Add(((entry.m_timeSelf + entry.m_timeChildren) * 1000.0).ToString("0.00000"));
                }
                else
                {
                    item.SubItems.Add(entry.m_count.ToString());
                    item.SubItems.Add((entry.m_timeSelf).ToString("0.00000"));
                    item.SubItems.Add((entry.m_timeChildren).ToString("0.00000"));
                    item.SubItems.Add(((entry.m_timeSelf + entry.m_timeChildren)).ToString("0.00000"));
                }

                profileListView.Items.Add(item);
            }

            profileListView.Sort();
            profileListView.EndUpdate();
        }
        public LuaProfileResultsView(IManager manager, Document doc)
            : base(manager, doc)
        {
            InitializeComponent();

            m_comparer = new ListViewItemComparer();
            profileListView.ListViewItemSorter = m_comparer;
            m_displayMode = DisplayMode.Seconds;

            m_totalTime = 0;
            LuaProfileResultsDocument profileDoc = (LuaProfileResultsDocument)Document;

            foreach (LuaProfileEntry entry in profileDoc.Functions)
            {
                m_totalCount        += entry.m_count;
                m_totalTime         += entry.m_timeSelf;
                m_totalTimeChildren += entry.m_timeChildren;
            }

            toolStripComboBox1.Text = m_displayMode.ToString();

            UpdateList();
        }