public static void EnteringMethod(string methodName) { if (!shouldProfile) return; try { // Debug.WriteLine("Entering " + methodName); DateTime startTime = DateTime.Now; Call parent = Parent(); var call = new Call(methodName, parent); if (parent.HasChild(call)) { call = parent.GetChild(call); } else { parent.Children.Add(call); } call.IncrementCount(); Stack.Push(call); call.Enter(startTime); } catch (Exception e) { Debug.WriteLine(e); throw; } }
public ProfilerOutputWindow(Call call) { this.call = call; InitializeComponent(); DataContext = call; }
public static void StopProfiling() { shouldProfile = false; var threadRoots = new List<Call>(stacksPerThread.Values.Cast<Stack<Call>>().Select(stack => Root(stack))); Debug.WriteLine("Number of threads - " + threadRoots.Count); var root = new Call("all threads", null); root.Children.AddRange(threadRoots); ProfilerOutputWindow = new ProfilerOutputWindow(root); ProfilerOutputWindow.Show(); }
public Call(string methodName, Call parent) { this.methodName = methodName; this.parent = parent; }
private int Comparison(Call x, Call y) { return y.Duration.CompareTo(x.Duration); }
public bool HasChild(Call call) { return GetChild(call) != null; }
public Call GetChild(Call call) { return Children.FirstOrDefault(call1 => call1.FullName == call.FullName); }