public void StartTrace() { MethodBase methodBase = new StackTrace().GetFrame(1).GetMethod(); MethodTracer methodTracer = new MethodTracer(methodBase.ReflectedType.Name, methodBase.Name); ThreadTracer threadTracer = GetThreadTracer(Thread.CurrentThread.ManagedThreadId); threadTracer.StartTrace(methodTracer); }
public void StartTrace() { if (_currentMethodTracer != null) { _methodTracers.Push(_currentMethodTracer); } _currentMethodTracer = new MethodTracer(); _currentMethodTracer.StartTrace(); }
internal void StopTrace() { if (MethodsInThread.Count == 0) { throw new InvalidOperationException("Can't stop tracing method that doesn't exist"); } MethodTracer popedMethod = MethodsInThread.Pop(); popedMethod.StopTrace(); }
internal void StartTrace(MethodTracer method) { if (methodsStack.Count > 0) { MethodTracer lastMethod = methodsStack.Peek(); lastMethod.Methods.Add(method); } method.StartTrace(); methodsStack.Push(method); }
private void AddMethod(MethodTracer method) { if (MethodsInThread.Count > 0) { MethodsInThread.Peek().AddInnerMethod(method); } else { TracedMethods.Add(method); } MethodsInThread.Push(method); }
internal void StopTrace() { MethodTracer lastMethod = methodsStack.Pop(); lastMethod.StopTrace(); if (methodsStack.Count == 0) { Methods.Add(lastMethod); TotalElapsedTime += lastMethod.ElapsedTime; } }
internal MethodTracer GetTraceResult() { var result = new MethodTracer(ClassName, MethodName); result.ElapsedTime = ElapsedTime; foreach (var method in Methods) { result.Methods.Add(method.GetTraceResult()); } return(result); }
public void StartTrace() { MethodBase methodBase = new StackTrace().GetFrame(1).GetMethod(); string methodName = methodBase.Name; string className = methodBase.ReflectedType.Name; MethodTracer methodTracer = new MethodTracer(methodName, className); int threadId = Thread.CurrentThread.ManagedThreadId; ThreadTracer currentThreadTracer = traceResult.GetThreadTracer(threadId); if (currentThreadTracer == null) { currentThreadTracer = new ThreadTracer(threadId); currentThreadTracer = traceResult.AddThreadTracer(threadId, currentThreadTracer); } currentThreadTracer.StartTrace(methodTracer); }
public void StopTrace() { _currentMethodTracer.StopTrace(); StackTrace stackTrace = new StackTrace(); MethodBase method = stackTrace.GetFrame(2).GetMethod(); string methodName = method.Name; string className = method.ReflectedType.Name; double methodExecutionTime = _currentMethodTracer.GetExecutionTime(); List <MethodInformation> methodInfos = _currentMethodTracer.GetChildMethods(); MethodInformation methodInfo = new MethodInformation(methodName, className, methodExecutionTime, methodInfos); if (_methodTracers.Count > 0) { _currentMethodTracer = _methodTracers.Pop(); _currentMethodTracer.AddChildMethod(methodInfo); } else { _methodInfoList.Add(methodInfo); _currentMethodTracer = null; } }
internal void StartTrace(MethodTracer method) { AddMethod(method); method.StartTrace(); }
internal void AddInnerMethod(MethodTracer method) { InnerMethods.Add(method); }