internal ThreadTracer AddThreadTracer(int id, ThreadTracer value) { if (ThreadTracer.TryAdd(id, value)) { return(GetThreadTracer(id)); } return(null); }
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); }
internal ThreadTracer GetThreadTracer(int id) { ThreadTracer threadTracer; if (ThreadTracer.TryGetValue(id, out threadTracer)) { return(threadTracer); } return(null); }
public void StartTrace() { ThreadTracer threadTracer = GetCurrentThreadTracer(); if (threadTracer == null) { int currentThreadId = Thread.CurrentThread.ManagedThreadId; threadTracer = new ThreadTracer(); _threadTracers.TryAdd(currentThreadId, threadTracer); } threadTracer.StartTrace(); }
internal ThreadTracer GetTraceResult() { var result = new ThreadTracer(Id); result.TotalElapsedTime = TotalElapsedTime; foreach (var method in Methods) { result.Methods.Add(method.GetTraceResult()); } return(result); }
private ThreadTracer GetThreadTracer(int id) { lock (locker) { if (!threads.TryGetValue(id, out ThreadTracer thread)) { thread = new ThreadTracer(id); threads.Add(id, thread); } return(thread); } }
public void StopTrace() { int threadId = Thread.CurrentThread.ManagedThreadId; ThreadTracer threadTracer = traceResult.GetThreadTracer(threadId); if (threadTracer != null) { threadTracer.StopTrace(); } else { throw new InvalidOperationException("There are no one method to stop tracing"); } }
public void StopTrace() { ThreadTracer threadTracer = GetCurrentThreadTracer(); threadTracer.StopTrace(); int currentThreadId = Thread.CurrentThread.ManagedThreadId; ThreadInformation threadInfo = GetThreadInfoById(currentThreadId); if (threadInfo == null) { List <MethodInformation> threadMethodInfos = threadTracer.GetThreadMethodList(); threadInfo = new ThreadInformation(currentThreadId, threadMethodInfos); _threadsInfo.TryAdd(currentThreadId, threadInfo); } }
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); }