示例#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);
 }