public void Intercept(IInvocation invocation) { if (currentElement.Value.Value != null) currentElement.Value.Value.Stop(); var sw = new Stopwatch(); var newChild = currentElement.AddChild(KV.Create(invocation.MethodInvocationTarget, sw)); currentElement = newChild; sw.Start(); try { invocation.Proceed(); } finally { sw.Stop(); currentElement = currentElement.Parent; if (currentElement.Value.Value != null) currentElement.Value.Value.Start(); } }
internal CompoundChild(String name, Node[] childNodes) : base(name) { this.childNodes = childNodes; }
public Node<KeyValuePair<MethodInfo, TimeSpan>> GetProfile() { var node = new Node<KeyValuePair<MethodInfo, TimeSpan>>(null, new KeyValuePair<MethodInfo, TimeSpan>(null, new TimeSpan())); node.Children.AddRange(currentElement.Children.Select(c => GetProfile(c, node))); return node; }
public void Clear() { currentElement = new Node<KeyValuePair<MethodInfo, Stopwatch>>(null, new KeyValuePair<MethodInfo, Stopwatch>(null, null)); }
private Node<KeyValuePair<MethodInfo, TimeSpan>> GetProfile(Node<KeyValuePair<MethodInfo, Stopwatch>> n, Node<KeyValuePair<MethodInfo, TimeSpan>> parent) { var node = new Node<KeyValuePair<MethodInfo, TimeSpan>>(parent, KV.Create(n.Value.Key, n.Value.Value.Elapsed)); node.Children.AddRange(n.Children.Select(c => GetProfile(c, node))); return node; }