Example #1
0
 public void StartTrace()
 {
     if (CurrentMethodTracer != null)
     {
         //CurrentMethodTracer.StopTrace();
         MethodTracers.Push(CurrentMethodTracer);
     }
     CurrentMethodTracer = new MethodTracer();
     CurrentMethodTracer.StartTrace();
 }
Example #2
0
        public void StopTrace()
        {
            MethodTracer lastUnstoppedMethodTracer = sUnstoppedMethodTracers.Pop();

            lastUnstoppedMethodTracer.StopTrace();
            if (!sUnstoppedMethodTracers.Any())
            {
                lFirstLvlMethodTracers.Add(lastUnstoppedMethodTracer);
                Time += lastUnstoppedMethodTracer.Time;
            }
        }
Example #3
0
        public void StartTrace()
        {
            MethodTracer methodTracer = new MethodTracer();

            if (sUnstoppedMethodTracers.Count > 0)
            {
                MethodTracer lastUnstoppedMethodTracer = sUnstoppedMethodTracers.Peek();
                lastUnstoppedMethodTracer.lInnerMethodTracers.Add(methodTracer);
            }
            sUnstoppedMethodTracers.Push(methodTracer);
            methodTracer.StartTrace();
        }
Example #4
0
        public static MethodTracerResult GetTraceResult(MethodTracer methodTracer)
        {
            MethodTracerResult methodTracerResult = new MethodTracerResult();

            methodTracerResult.ClassName  = methodTracer.ClassName;
            methodTracerResult.MethodName = methodTracer.MethodName;
            methodTracerResult.Time       = methodTracer.Time;
            methodTracerResult.lInnerMethodTracerResults = new List <MethodTracerResult>();

            foreach (var innerMethodTracer in methodTracer.lInnerMethodTracers)
            {
                methodTracerResult.lInnerMethodTracerResults.Add(MethodTracerResult.GetTraceResult(innerMethodTracer));
            }

            return(methodTracerResult);
        }
Example #5
0
        public void StopTrace()
        {
            CurrentMethodTracer.StopTrace();
            StackTrace        stackTrace          = new StackTrace();
            string            methodName          = stackTrace.GetFrame(2).GetMethod().Name;
            string            className           = stackTrace.GetFrame(2).GetMethod().ReflectedType.Name;
            double            methodExecutionTime = CurrentMethodTracer.GetExecutionTime();
            List <MethodInfo> methodInfos         = CurrentMethodTracer.GetChildMethods();
            MethodInfo        methodInfo          = new MethodInfo(methodName, className, methodExecutionTime, methodInfos);

            if (MethodTracers.Count > 0)
            {
                CurrentMethodTracer = MethodTracers.Pop();
                CurrentMethodTracer.AddChildMethod(methodInfo);
            }
            else
            {
                MethodInfoList.Add(methodInfo);
                CurrentMethodTracer = null;
            }
        }