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

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