public void StartProfiling(StartProfilingInfo profilingInfo) { if (profilingInfo is StartProfilingProcessInfo) { var options = OpenOptionsDialog(); CurrentSession = KrofilerSession.CreateFromProcess(((StartProfilingProcessInfo)profilingInfo).ExePath, ((StartProfilingProcessInfo)profilingInfo).Args, options); Settings.Instance.RecentlyRecordedFiles.Remove(CurrentSession.MlpdPath); Settings.Instance.RecentlyRecordedFiles.Insert(0, CurrentSession.MlpdPath); Settings.Instance.Save(); } else if (profilingInfo is StartProfilingFromFileInfo) { CurrentSession = KrofilerSession.CreateFromFile(((StartProfilingFromFileInfo)profilingInfo).MlpdFilePath); } else { throw new NotSupportedException($"{profilingInfo.GetType().FullName} is not supported."); } CurrentSession.NewHeapshot += HandleNewHeapshot; CurrentSession.AllocationsPerSecond += AllocationsPerSecond; CurrentSession.CountersDescriptionsAdded += CountersDescriptionsAdded; CurrentSession.CounterSamplesAdded += CounterSamplesAdded; CurrentSession.UserError += UserError; CurrentSession.StartParsing(); }
void HandleNewHeapshot(KrofilerSession session, Heapshot hs) { //hs.BuildReferencesFrom(); //Console.WriteLine("Hs:" + hs.Name); //Console.WriteLine("Objects Count:" + hs.ObjectsInfoMap.Count); //int count = 0; //foreach (var obj in hs.ObjectsInfoMap.Values) { // if (obj.ReferencesFrom.Count == 0 && !hs.Roots.ContainsKey(obj.ObjAddr)) { // count++; // Console.WriteLine($"{obj.ObjAddr} type:{session.GetTypeName(obj.TypeId)}"); // foreach (var b in obj.Allocation.Backtrace) { // Console.WriteLine(" " + session.GetMethodName(b)); // } // } //} //Console.WriteLine("Orphans count:" + count); Application.Instance.AsyncInvoke(delegate { listViewLeft.Items.Add(new ListItem() { Text = hs.Name, Tag = hs }); listViewRight.Items.Add(new ListItem() { Text = hs.Name, Tag = hs }); }); }
public ObjectListTab(KrofilerSession session, Heapshot heapshot, Dictionary <long, List <ObjectInfo> > typesToObjectsListMap) { this.typesToObjectsListMap = typesToObjectsListMap; this.session = session; this.heapshot = heapshot; this.Orientation = Orientation.Horizontal; CreateTypesView(); filterTypesTextBox = new TextBox(); filterTypesTextBox.TextChanged += FilterTypesTextBox_TextChanged; this.SplitterWidth = 10; var filterAndTypesStackLayout = new StackLayout(); filterAndTypesStackLayout.Items.Add(new StackLayoutItem(filterTypesTextBox, HorizontalAlignment.Stretch)); filterAndTypesStackLayout.Items.Add(new StackLayoutItem(typesGrid, HorizontalAlignment.Stretch, true)); this.Panel1 = filterAndTypesStackLayout; CreateObjectsView(); var splitter2 = new Splitter() { Orientation = Orientation.Horizontal }; splitter2.SplitterWidth = 5; splitter2.Panel1 = objectsGrid; objectPanel = new ObjectDetailsPanel(session, this.heapshot); objectPanel.InsertTab += (a, b) => InsertTab?.Invoke(a, b ?? this); splitter2.Panel2 = objectPanel; Panel2 = splitter2; this.Position = (int)Screen.PrimaryScreen.Bounds.Width / 3; }
public static KrofilerSession CreateFromFile(string fileName) { var session = new KrofilerSession(); session.fileToProcess = fileName; return(session); }
public RetentionGraph(KrofilerSession session, Heapshot heapshot) { this.heapshot = heapshot; this.session = session; Width = 1000; Height = 2000; }
public static KrofilerSession CreateFromProcess(string executableName, string args, ProfileAppOptions options) { var session = new KrofilerSession(); session.runner = new ProfilerRunner(); session.runner.Start(executableName, args, options); session.fileToProcess = session.runner.LogFilePath; return(session); }
public CompareHeapshotsTab(KrofilerSession session, Heapshot hs1, Heapshot hs2) { this.session = session; if (hs2.Id > hs1.Id) { newHeapshot = hs2; oldHeapshot = hs1; } else { newHeapshot = hs1; oldHeapshot = hs2; } var diff = new DiffHeap(oldHeapshot, newHeapshot); var newObjects = diff.NewObjects.GroupBy(addr => addr.TypeId).ToDictionary(d => d.Key, d => d.ToList()); var deleted = diff.DeletedObjects.GroupBy(addr => addr.TypeId).ToDictionary(d => d.Key, d => d.ToList()); var allObjectsInOldHs = oldHeapshot.TypesToObjectsListMap; var allObjectsInNewHs = newHeapshot.TypesToObjectsListMap; var hashTableAllTypes = new HashSet <long>(); foreach (var t in allObjectsInOldHs) { hashTableAllTypes.Add(t.Key); } foreach (var t in allObjectsInNewHs) { hashTableAllTypes.Add(t.Key); } foreach (var typeId in hashTableAllTypes) { typesCollection.Add(new TypeChangeInfo { TypeId = typeId, TypeName = session.GetTypeName(typeId), NewObjects = newObjects.ContainsKey(typeId) ? newObjects[typeId] : EmptyList, DeadObjects = deleted.ContainsKey(typeId) ? deleted[typeId] : EmptyList, OldHsObjects = allObjectsInOldHs.ContainsKey(typeId) ? allObjectsInOldHs[typeId] : EmptyList, NewHsObjects = allObjectsInNewHs.ContainsKey(typeId) ? allObjectsInNewHs[typeId] : EmptyList }); } filterTypesTextBox = new TextBox(); filterTypesTextBox.TextChanged += FilterTypesTextBox_TextChanged; CreateTypesView(); var filterAndTypesStackLayout = new StackLayout(); filterAndTypesStackLayout.Items.Add(new StackLayoutItem(filterTypesTextBox, HorizontalAlignment.Stretch)); filterAndTypesStackLayout.Items.Add(new StackLayoutItem(typesGrid, HorizontalAlignment.Stretch, true)); Content = filterAndTypesStackLayout; }
internal StackFrame GetStackFrame(KrofilerSession session, long[] frame, int index) { if (frame.Length == index) { return(this); } if (!Children.ContainsKey(frame[index])) { Children[frame[index]] = new StackFrame(session, frame[index]) { Parent = this }; } return(Children[frame[index]].GetStackFrame(session, frame, index + 1)); }
public void StartProfiling(StartProfilingInfo profilingInfo) { if (profilingInfo is StartProfilingProcessInfo) { CurrentSession = KrofilerSession.CreateFromProcess(((StartProfilingProcessInfo)profilingInfo).ExePath); } else if (profilingInfo is StartProfilingFromFileInfo) { CurrentSession = KrofilerSession.CreateFromFile(((StartProfilingFromFileInfo)profilingInfo).MlpdFilePath); } else { throw new NotSupportedException($"{profilingInfo.GetType().FullName} is not supported."); } CurrentSession.NewHeapshot += HandleNewHeapshot; CurrentSession.StartParsing(); }
void HandleNewHeapshot(KrofilerSession session, Heapshot hs) { Application.Instance.Invoke(delegate { var hsButton = new Button { Text = hs.Name }; listViewLeft.Items.Add(new ListItem() { Text = hs.Name, Tag = hs }); listViewRight.Items.Add(new ListItem() { Text = hs.Name, Tag = hs }); hsButton.Click += delegate { InsertTab(new ObjectListTab(session, hs, hs.TypesToObjectsListMap), this); }; commandButtonsStack.Items.Add(hsButton); }); }
private void UserError(KrofilerSession session, string message, string details) { Application.Instance.Invoke(delegate { Eto.Forms.MessageBox.Show(details, message, type: MessageBoxType.Error); }); }
private void AllocationsPerSecond(KrofilerSession session, TimeSpan time, double objects, double bytes) { Application.Instance.AsyncInvoke(delegate { allocationsGraph.AddSample(time, objects, bytes); }); }
public Heapshot(KrofilerSession session, int id) { Id = id; Session = session; }
public StackFrame(KrofilerSession session, long methodId) { this.session = session; this.methodId = methodId; }
public KrofilerLogEventVisitor(KrofilerSession session) { this.session = session; }