Exemple #1
0
 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();
 }
Exemple #2
0
 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
         });
     });
 }
Exemple #3
0
        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);
        }
Exemple #5
0
 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);
        }
Exemple #7
0
        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;
        }
Exemple #8
0
 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));
 }
Exemple #9
0
 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();
 }
Exemple #10
0
 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);
     });
 }
Exemple #11
0
 private void UserError(KrofilerSession session, string message, string details)
 {
     Application.Instance.Invoke(delegate {
         Eto.Forms.MessageBox.Show(details, message, type: MessageBoxType.Error);
     });
 }
Exemple #12
0
 private void AllocationsPerSecond(KrofilerSession session, TimeSpan time, double objects, double bytes)
 {
     Application.Instance.AsyncInvoke(delegate {
         allocationsGraph.AddSample(time, objects, bytes);
     });
 }
Exemple #13
0
 public Heapshot(KrofilerSession session, int id)
 {
     Id      = id;
     Session = session;
 }
Exemple #14
0
 public StackFrame(KrofilerSession session, long methodId)
 {
     this.session  = session;
     this.methodId = methodId;
 }
Exemple #15
0
 public KrofilerLogEventVisitor(KrofilerSession session)
 {
     this.session = session;
 }