示例#1
0
 public void Push(string name)
 {
     if (this.m_nodes_size >= this.m_nodes.Count)
     {
         this.m_nodes.Add(new Profiler.Node
         {
             Timer = new Timer()
         });
     }
     Profiler.Node node = this.m_nodes[this.m_nodes_size];
     node.Name  = name;
     node.Depth = this.m_stack.Count;
     node.Timer.Reset();
     this.m_stack.Add(node);
     this.m_nodes_size++;
 }
示例#2
0
        public void Dump()
        {
            Console.WriteLine("");
            Console.WriteLine("--- frame " + Common.FrameCount + "'s timers:");
            Common.Assert(this.m_stack.Count == 0, "number of Profiler Push/Push doesn't match");
            for (int i = 0; i < this.m_nodes_size; i++)
            {
                Console.WriteLine(string.Concat(new object[]
                {
                    new string('\t', this.m_nodes[i].Depth),
                    this.m_nodes[i].Name,
                    " ",
                    this.m_nodes[i].Duration,
                    " ms"
                }));
            }
            Dictionary <string, float> dictionary  = new Dictionary <string, float>();
            Dictionary <string, int>   dictionary2 = new Dictionary <string, int>();

            for (int i = 0; i < this.m_nodes_size; i++)
            {
                Profiler.Node node = this.m_nodes[i];
                if (!dictionary.ContainsKey(node.Name))
                {
                    dictionary.Add(node.Name, 0f);
                    dictionary2.Add(node.Name, 0);
                }
                Dictionary <string, float> dictionary3;
                string name;
                (dictionary3 = dictionary)[name = node.Name] = dictionary3[name] + node.Duration;
                Dictionary <string, int> dictionary4;
                (dictionary4 = dictionary2)[name = node.Name] = dictionary4[name] + 1;
            }
            Console.WriteLine("");
            Console.WriteLine("--- frame " + Common.FrameCount + "'s timers totals:");
            foreach (KeyValuePair <string, float> current in dictionary)
            {
                Console.WriteLine("total for {0} = {1} ms ({2} calls)", current.Key, current.Value, dictionary2[current.Key]);
            }
        }