Пример #1
0
        public void StopTrace()
        {
            ThreadResult currThread = traceResult.GetCurrThread(Thread.CurrentThread.ManagedThreadId);
            MethodResult method     = currThread.PopCurrMethod();

            method.StopTiming();
        }
Пример #2
0
        public TraceResult GetTraceResult()
        {
            TraceResult tr = new TraceResult();

            tr.threads = new List <ThreadResult>();
            foreach (int index in dict.Keys)
            {
                ThreadResult thrres = new ThreadResult();
                thrres.threadId = index;
                thrres.methods  = dict[index].children;
                thrres.CalculateTime();
                tr.Add(thrres);
            }
            return(tr);
        }
Пример #3
0
        protected internal ThreadResult DeepCopy()
        {
            ThreadResult threadCopy = new ThreadResult
            {
                id      = id,
                time    = time,
                methods = new List <MethodResult>()
            };

            foreach (MethodResult innerMethod in methods)
            {
                threadCopy.methods.Add(innerMethod.DeepCopy());
            }
            return(threadCopy);
        }
Пример #4
0
        public void StartTrace()
        {
            ThreadResult currThread = traceResult.SetCurrThread(Thread.CurrentThread.ManagedThreadId);
            MethodBase   methodBase = new StackTrace(1).GetFrame(0).GetMethod();
            var          method     = new MethodResult(methodBase);

            if (currThread.IsFirstLevelMethod())
            {
                currThread.AddMethod(method);
            }
            else
            {
                currThread.GetCurrMethod().AddMethod(method);
            }
            currThread.AddDepthMethod(method);
            method.StartTiming();
        }
Пример #5
0
        public void StartTrace()
        {
            int threadId = Thread.CurrentThread.ManagedThreadId;

            if (!threadResults.ContainsKey(threadId))
            {
                var threadResult = new ThreadResult();
                threadResults.TryAdd(threadId, threadResult);
            }

            var        stackTrace   = new StackTrace();
            MethodBase tracedMethod = stackTrace.GetFrame(1).GetMethod();

            var temp = new TraceResult(tracedMethod.Name, tracedMethod.DeclaringType.Name);

            threadResults[threadId].AddTraceResult(temp);

            var stopwatch = new Stopwatch();

            stopwatches.TryAdd(tracedMethod.GetHashCode(), stopwatch);

            stopwatch.Start();
        }
Пример #6
0
 internal void Add(ThreadResult threadResult)
 {
     threads.Add(threadResult);
 }