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

            if (ThreadTracer.TryGetValue(id, out threadTracer))
            {
                return(threadTracer);
            }
            return(null);
        }
Esempio n. 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();
        }
Esempio n. 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);
        }
Esempio n. 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);
            }
        }
Esempio n. 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");
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 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);
        }