public void StartTrace() { if (CurrentMethodTracer != null) { //CurrentMethodTracer.StopTrace(); MethodTracers.Push(CurrentMethodTracer); } CurrentMethodTracer = new MethodTracer(); CurrentMethodTracer.StartTrace(); }
public void StopTrace() { MethodTracer lastUnstoppedMethodTracer = sUnstoppedMethodTracers.Pop(); lastUnstoppedMethodTracer.StopTrace(); if (!sUnstoppedMethodTracers.Any()) { lFirstLvlMethodTracers.Add(lastUnstoppedMethodTracer); Time += lastUnstoppedMethodTracer.Time; } }
public void StartTrace() { MethodTracer methodTracer = new MethodTracer(); if (sUnstoppedMethodTracers.Count > 0) { MethodTracer lastUnstoppedMethodTracer = sUnstoppedMethodTracers.Peek(); lastUnstoppedMethodTracer.lInnerMethodTracers.Add(methodTracer); } sUnstoppedMethodTracers.Push(methodTracer); methodTracer.StartTrace(); }
public static MethodTracerResult GetTraceResult(MethodTracer methodTracer) { MethodTracerResult methodTracerResult = new MethodTracerResult(); methodTracerResult.ClassName = methodTracer.ClassName; methodTracerResult.MethodName = methodTracer.MethodName; methodTracerResult.Time = methodTracer.Time; methodTracerResult.lInnerMethodTracerResults = new List <MethodTracerResult>(); foreach (var innerMethodTracer in methodTracer.lInnerMethodTracers) { methodTracerResult.lInnerMethodTracerResults.Add(MethodTracerResult.GetTraceResult(innerMethodTracer)); } return(methodTracerResult); }
public void StopTrace() { CurrentMethodTracer.StopTrace(); StackTrace stackTrace = new StackTrace(); string methodName = stackTrace.GetFrame(2).GetMethod().Name; string className = stackTrace.GetFrame(2).GetMethod().ReflectedType.Name; double methodExecutionTime = CurrentMethodTracer.GetExecutionTime(); List <MethodInfo> methodInfos = CurrentMethodTracer.GetChildMethods(); MethodInfo methodInfo = new MethodInfo(methodName, className, methodExecutionTime, methodInfos); if (MethodTracers.Count > 0) { CurrentMethodTracer = MethodTracers.Pop(); CurrentMethodTracer.AddChildMethod(methodInfo); } else { MethodInfoList.Add(methodInfo); CurrentMethodTracer = null; } }