private void Cleanup() { while (tabControl.TabPages.Count > 1) { tabControl.TabPages.RemoveAt(1); } listView.Items.Clear(); toolStripStatusLabel1.Text = ""; _curFile = null; _openTabs.Clear(); GC.Collect(); }
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; }