Beispiel #1
0
        private void InsertToTraceTree(List <MethodTraceResultClass> rootList, MethodTraceResultClass elem)
        {
            List <MemberIdentifier> callTree = MakeUpMethodCallTree();
            MethodTraceResultClass  traceResultElem;

            if (callTree.Count == 0)
            {
                rootList.Add(elem);
            }
            else
            {
                bool found = false;
                foreach (MemberIdentifier mi in callTree)
                {
                    traceResultElem = FindElement(rootList, mi.methodName, mi.className);
                    if (traceResultElem != null)
                    {
                        traceResultElem.calledMethods.Add(elem);
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    rootList.Add(elem);
                }
            }
        }
Beispiel #2
0
 public void StopTrace()
 {
     lock (locker)
     {
         StackFrame             frame           = new StackFrame(1);
         MethodTraceResultClass traceResultElem = FindElement(_methodsTraceList,
                                                              frame.GetMethod().Name, frame.GetMethod().DeclaringType.Name, Thread.CurrentThread.ManagedThreadId);
         if (traceResultElem != null)
         {
             traceResultElem.stopwatch.Stop();
             traceResultElem.execTime = traceResultElem.stopwatch.ElapsedMilliseconds;
             ToFormTraceList(_methodsTraceList, _traceList);
             ThreadTraceResultClass curThread = _traceList.Find(x => x.id == Thread.CurrentThread.ManagedThreadId);
             curThread.execTime = CountThreadExecTime(curThread.calledMethods);
         }
     }
 }
Beispiel #3
0
        public void StartTrace()
        {
            MethodTraceResultClass curTraceResult = new MethodTraceResultClass();

            StackFrame frame = new StackFrame(1);

            curTraceResult.methodName    = frame.GetMethod().Name;
            curTraceResult.className     = frame.GetMethod().DeclaringType.Name;
            curTraceResult.threadId      = Thread.CurrentThread.ManagedThreadId;
            curTraceResult.stopwatch     = new Stopwatch();
            curTraceResult.execTime      = 0;
            curTraceResult.calledMethods = new List <MethodTraceResultClass>();

            lock (locker)
            {
                InsertToTraceTree(_methodsTraceList, curTraceResult);
            }
            curTraceResult.stopwatch.Start();
        }