Ejemplo n.º 1
0
        public CallTab(string blockName, ICallDetails callDetails)
        {
            _blockName = blockName;
            InitializeComponent();
            listViewCallers.ListViewItemSorter = _callersColumnSorter;
            listViewCallees.ListViewItemSorter = _calleesColumnSorter;

            foreach (var caller in callDetails.Callers)
            {
                listViewCallers.Items.Add(new ListViewItem(new ListViewItem.ListViewSubItem[]
                {
                    new ListViewItem.ListViewSubItem()
                    {
                        Text = caller.Key.ToString(), Tag = caller.Key.ToString()
                    },
                    new ListViewItem.ListViewSubItem()
                    {
                        Text = caller.Value.ToString(), Tag = caller.Value
                    },
                }, 0));
            }

            callDetails.Callees.Add("Self", callDetails.TimeSelf);

            foreach (var callee in callDetails.Callees.OrderByDescending(t => t.Value))
            {
                var percentage = callDetails.TimeTotal == 0.0f ? 0.0f : (callee.Value / callDetails.TimeTotal) * 100;

                listViewCallees.Items.Add(new ListViewItem(new ListViewItem.ListViewSubItem[]
                {
                    new ListViewItem.ListViewSubItem()
                    {
                        Text = callee.Key.ToString(), Tag = callee.Key.ToString()
                    },
                    new ListViewItem.ListViewSubItem()
                    {
                        Text = percentage.ToString("0.##"), Tag = percentage
                    },
                    new ListViewItem.ListViewSubItem()
                    {
                        Text = callee.Value.FormatTime(), Tag = callee.Value
                    },
                }, 0));
            }

            ListViewColor.Update(listViewCallees, 1);
        }
Ejemplo n.º 2
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Cleanup();
            this.ClearWarnings();

            string path = openFileDialog1.FileName;

            if (path.EndsWith(".wseprfb"))
            {
                _curFile = new BinaryProfilerFile(path);
            }
            else
            {
                _curFile = new TextProfilerFile(path);
            }

            try
            {
                _curFile.Parse("");
            }
            catch (ErrorException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Critical Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                Application.Exit();
            }

            foreach (var info in _curFile.CallInfos)
            {
                float selfSum    = info.SumSelf;
                float fullSum    = info.SumTotal;
                float selfAvg    = info.AvgSelf;
                float fullAvg    = info.AvgTotal;
                float selfMin    = info.MinSelf;
                float fullMin    = info.MinTotal;
                float selfMax    = info.MaxSelf;
                float fullMax    = info.MaxTotal;
                float percentage = (fullSum / _curFile.TimeTotal) * 100;

                listView.Items.Add(new ListViewItem(new ListViewItem.ListViewSubItem[]
                {
                    new ListViewItem.ListViewSubItem()
                    {
                        Text = info.ToString(), Tag = info.ToString()
                    },
                    new ListViewItem.ListViewSubItem()
                    {
                        Text = info.Count.ToString(), Tag = info.Count
                    },
                    new ListViewItem.ListViewSubItem()
                    {
                        Text = percentage.ToString("0.##"), Tag = percentage
                    },
                    new ListViewItem.ListViewSubItem()
                    {
                        Text = selfSum.FormatTime(), Tag = selfSum
                    },
                    new ListViewItem.ListViewSubItem()
                    {
                        Text = fullSum.FormatTime(), Tag = fullSum
                    },
                    new ListViewItem.ListViewSubItem()
                    {
                        Text = selfAvg.FormatTime(), Tag = selfAvg
                    },
                    new ListViewItem.ListViewSubItem()
                    {
                        Text = fullAvg.FormatTime(), Tag = fullAvg
                    },
                    new ListViewItem.ListViewSubItem()
                    {
                        Text = selfMin.FormatTime(), Tag = selfMin
                    },
                    new ListViewItem.ListViewSubItem()
                    {
                        Text = fullMin.FormatTime(), Tag = fullMin
                    },
                    new ListViewItem.ListViewSubItem()
                    {
                        Text = selfMax.FormatTime(), Tag = selfMax
                    },
                    new ListViewItem.ListViewSubItem()
                    {
                        Text = fullMax.FormatTime(), Tag = fullMax
                    },
                }, 0));
            }

            ListViewColor.Update(listView, 2);

            _curFile.Close();
            Text = NAME + " (" + Path.GetFileName(openFileDialog1.FileName) + ")";
            toolStripStatusLabel1.Text = _curFile.InfoString;
        }