public TraceResultThreadNode()
        {
            this.TotalTime = new TimeSpan();

            this.methodNodesStack = new Stack <TraceResultMethodNode>();
            this.MethodNodesList  = new List <TraceResultMethodNode>();

            this.currentMethodNode = null;
        }
Example #2
0
        private void PrintMethodNode(TraceResultMethodNode methodNode, string indent)
        {
            Console.WriteLine("{0}Method: {1}", indent, methodNode.MethodName);
            Console.WriteLine("{0}Class: {1}", indent, methodNode.ClassName);
            Console.WriteLine("{0}Params: {1}", indent, methodNode.ParamCount);
            Console.WriteLine("{0}Time (ms): {1}", indent, methodNode.TotalTime.TotalMilliseconds);

            string newIndent = indent + baseIndent;

            foreach (var node in methodNode.InsertedNodes)
            {
                PrintMethodNode(node, newIndent);
                Console.WriteLine();
            }
        }
        public void FinishNode()
        {
            TraceResultMethodNode finishNode = this.methodNodesStack.Pop();

            finishNode.FinishNode();

            if (this.methodNodesStack.Count > 0)
            {
                this.currentMethodNode = this.methodNodesStack.Peek();
            }
            else
            {
                this.currentMethodNode = null;

                this.TotalTime += finishNode.TotalTime;
            }
        }
        public void StartNode(string methodName,
                              string className, int paramCount)
        {
            TraceResultMethodNode newNode = new
                                            TraceResultMethodNode(methodName, className, paramCount);

            if (this.currentMethodNode == null)
            {
                this.MethodNodesList.Add(newNode);
            }
            else
            {
                this.currentMethodNode.AddInsertedNode(newNode);
            }

            this.methodNodesStack.Push(newNode);

            newNode.StartNode();

            this.currentMethodNode = newNode;
        }
        private void AddMethodNode(XElement element, TraceResultMethodNode methodNode)
        {
            XElement method = new XElement("method");

            XAttribute methodName = new XAttribute("name", methodNode.MethodName);
            XAttribute className  = new XAttribute("class", methodNode.ClassName);
            XAttribute parameters = new XAttribute("params", methodNode.ParamCount);

            double     timeInMilliseconds = methodNode.TotalTime.TotalMilliseconds;
            XAttribute totalTime          = new XAttribute("time", timeInMilliseconds);

            method.Add(methodName);
            method.Add(className);
            method.Add(parameters);
            method.Add(totalTime);

            foreach (var node in methodNode.InsertedNodes)
            {
                AddMethodNode(method, node);
            }

            element.Add(method);
        }
 public void AddInsertedNode(TraceResultMethodNode newNode)
 {
     this.InsertedNodes.Add(newNode);
 }