Beispiel #1
0
        /*public List<TracedMethod> GetMethods()
         * {
         *  return methods;
         * }*/
        private void AddTime(long time)
        {
            TracedMethod tmpMethod = currentMethod;

            while (tmpMethod != null)
            {
                tmpMethod.AddTime(_timer.ElapsedMilliseconds);
                tmpMethod = tmpMethod.parent;
            }
            this._overallTime += _timer.ElapsedMilliseconds;
        }
Beispiel #2
0
 internal void StopTrace()
 {
     _timer.Stop();
     if (currentMethod != null)
     {
         currentMethod.timerPaused(_timer);
         currentMethod = currentMethod.parent;
     }
     this.AddTime(_timer.ElapsedMilliseconds);
     _timer.Reset();
     _timer.Start();
 }
        private XElement CreateMethodElement(TracedMethod tracedMethod)
        {
            var method = new XElement("method");

            method.Add(new XAttribute("name", tracedMethod.Name));
            method.Add(new XAttribute("class", tracedMethod.ClassName));
            method.Add(new XAttribute("time", tracedMethod.ExecutionTime));

            foreach (TracedMethod tracedNestedMethod in tracedMethod.NestedMethods)
            {
                method.Add(CreateMethodElement(tracedNestedMethod));
            }

            return(method);
        }
Beispiel #4
0
        private void AddMethodToTrace(MethodBase method)
        {
            var tracedMethod = new TracedMethod(method);

            if (stack.Count == 0)
            {
                tracedMethods.Add(tracedMethod);
            }
            else
            {
                stack.Peek().AddNestedMethod(tracedMethod);
            }

            stack.Push(tracedMethod);
        }
        private JObject CreateMethodsElement(TracedMethod tracedMethod)
        {
            var method = new JObject
            {
                { "name", new JValue(tracedMethod.Name) },
                { "class", new JValue(tracedMethod.ClassName) },
                { "time", new JValue(tracedMethod.ExecutionTime) }
            };

            var methods = new JArray();

            foreach (TracedMethod tracedNestedMethod in tracedMethod.NestedMethods)
            {
                methods.Add(CreateMethodsElement(tracedNestedMethod));
            }

            method.Add("methods", methods);

            return(method);
        }
Beispiel #6
0
        internal void StartTrace(/*at: */ MethodBase method)
        {
            TracedMethod newMethod = new TracedMethod(/*parent:*/ this.currentMethod);

            if (this.currentMethod != null)
            {
                //Console.WriteLine(timer.ElapsedMilliseconds);
                _timer.Stop();
                //Console.WriteLine(timer.ElapsedMilliseconds);
                this.AddTime(_timer.ElapsedMilliseconds);
                _timer.Reset();
                currentMethod.AddChild(newMethod);
            }
            else
            {
                methods.Add(newMethod);
            }
            newMethod.SetName(method.Name);
            newMethod.SetClass(method.ReflectedType.Name);
            this.currentMethod = newMethod;
            _timer.Start();
        }
Beispiel #7
0
 internal void AddNestedMethod(TracedMethod tracedMethod)
 {
     nestedMethods.Add(tracedMethod);
 }
Beispiel #8
0
 public TracedMethod(TracedMethod parent)
 {
     this.currentTimerTime = 0;
     this.children         = new List <TracedMethod>();
     this.parent           = parent;
 }
Beispiel #9
0
 internal void AddChild(TracedMethod childMethod)
 {
     this.children.Add(childMethod);
 }