예제 #1
0
        /// <summary>
        /// Starts tracing of the method from which this method is called
        /// </summary>
        public void StartTrace()
        {
            MethodTraceResult method = new MethodTraceResult();

            ThreadTraceResult thread = new ThreadTraceResult();

            threadStacks.TryAdd(thread.ID, new Stack <MethodTraceResult>());
            threadStacks[thread.ID].Push(method);

            method.StartStopwatch();
        }
예제 #2
0
        /// <summary>
        /// Stops tracing of current method, adds the result to the traceResult field
        /// </summary>
        public void StopTrace()
        {
            var method = threadStacks[Thread.CurrentThread.ManagedThreadId].Pop();

            method.StopStopwatch();

            if (threadStacks[Thread.CurrentThread.ManagedThreadId].Count > 0)
            {
                threadStacks[Thread.CurrentThread.ManagedThreadId].Peek().AddMethod(method);
            }
            else
            {
                ThreadTraceResult thread = traceResult.Threads.Find(t => t.ID == Thread.CurrentThread.ManagedThreadId);
                if (thread == null)
                {
                    thread = new ThreadTraceResult();
                    traceResult.AddThread(thread);
                }
                thread.AddMethod(method);
            }
        }
예제 #3
0
        private List <ThreadTraceResult> ToFormResultList()
        {
            List <ThreadTraceResult> resList = new List <ThreadTraceResult>();

            lock (locker)
            {
                foreach (ThreadTraceResultClass ttrc in _traceList)
                {
                    ThreadTraceResult newTtr = new ThreadTraceResult();
                    newTtr.id            = ttrc.id;
                    newTtr.execTime      = ttrc.execTime;
                    newTtr.calledMethods = new List <MethodTraceResult>();
                    if (ttrc.calledMethods.Count > 0)
                    {
                        CopyMethodsList(newTtr.calledMethods, ttrc.calledMethods);
                    }

                    resList.Add(newTtr);
                }
            }
            return(resList);
        }
예제 #4
0
 internal void AddThread(ThreadTraceResult thread) => Threads.Add(thread);