public void StartTrace() { MethodBase methodBase = new StackTrace().GetFrame(1).GetMethod(); MethodTracer methodTracer = new MethodTracer(methodBase.ReflectedType.Name, methodBase.Name); ThreadTracer curThreadTracer = AddOrGetThreadTracer(Thread.CurrentThread.ManagedThreadId); curThreadTracer.StartTraceMethod(methodTracer); }
internal void StartTraceMethod(MethodTracer methodTracer) { if (_unstopped.Count > 0) { MethodTracer lastUnstoppedMethodTracer = _unstopped.Peek(); lastUnstoppedMethodTracer.Inner.Add(methodTracer); } methodTracer.StartTrace(); _unstopped.Push(methodTracer); }
internal void StopTraceMethod() { MethodTracer lastStopped = _unstopped.Pop(); //rewrite with unstopped.peek().StopTrace() ? lastStopped.StopTrace(); if (!_unstopped.Any()) { ExtremeMethods.Add(lastStopped); TimeElapsed += lastStopped.ElapsedTime; } }
static internal MethodTracerResult GetResult(MethodTracer methodTracer) { MethodTracerResult result = new MethodTracerResult(); result.ClassName = methodTracer.ClassName; result.MethodName = methodTracer.MethodName; result.ElapsedTime = methodTracer.ElapsedTime; result.Inner = new List <MethodTracerResult>(); foreach (var innerMethodTracer in methodTracer.Inner) { result.Inner.Add(MethodTracerResult.GetResult(innerMethodTracer)); } return(result); }