예제 #1
0
 internal ThreadTracer AddThreadTracer(int id, ThreadTracer value)
 {
     if (ThreadTracer.TryAdd(id, value))
     {
         return(GetThreadTracer(id));
     }
     return(null);
 }
예제 #2
0
        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);
        }
예제 #3
0
        internal ThreadTracer GetThreadTracer(int id)
        {
            ThreadTracer threadTracer;

            if (ThreadTracer.TryGetValue(id, out threadTracer))
            {
                return(threadTracer);
            }
            return(null);
        }
예제 #4
0
        public void StartTrace()
        {
            ThreadTracer threadTracer = GetCurrentThreadTracer();

            if (threadTracer == null)
            {
                int currentThreadId = Thread.CurrentThread.ManagedThreadId;
                threadTracer = new ThreadTracer();
                _threadTracers.TryAdd(currentThreadId, threadTracer);
            }
            threadTracer.StartTrace();
        }
예제 #5
0
        internal ThreadTracer GetTraceResult()
        {
            var result = new ThreadTracer(Id);

            result.TotalElapsedTime = TotalElapsedTime;

            foreach (var method in Methods)
            {
                result.Methods.Add(method.GetTraceResult());
            }

            return(result);
        }
예제 #6
0
        private ThreadTracer GetThreadTracer(int id)
        {
            lock (locker)
            {
                if (!threads.TryGetValue(id, out ThreadTracer thread))
                {
                    thread = new ThreadTracer(id);
                    threads.Add(id, thread);
                }

                return(thread);
            }
        }
예제 #7
0
        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");
            }
        }
예제 #8
0
        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);
            }
        }
예제 #9
0
        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);
        }