public static LuaProfilerTreeViewItem Create(LuaProfiler.Sample sample, int depth, LuaProfilerTreeViewItem father)
        {
            LuaProfilerTreeViewItem mt = objectPool.GetObject();

            mt.ResetBySample(sample, depth, father);
            return(mt);
        }
        public void ResetBySample(LuaProfiler.Sample sample, int depth, LuaProfilerTreeViewItem father)
        {
            if (sample != null)
            {
                totalMemory = sample.costGC;
                totalTime   = (long)(sample.costTime * 1000000);
                displayName = sample.name;
            }
            else
            {
                totalMemory = 0;
                totalTime   = 0;
                displayName = "root";
            }
            totalCallTime = 1;
            averageTime   = totalTime / totalCallTime;

            this.id    = LuaProfilerTreeView.GetUniqueId();
            this.depth = depth;


            childs.Clear();
            if (sample != null)
            {
                for (int i = 0, imax = sample.childs.Count; i < imax; i++)
                {
                    var item = Create(sample.childs[i], depth + 1, this);
                    childs.Add(item);
                }
            }
            this.father = father;

            _frameCount = Time.frameCount;
        }
Ejemplo n.º 3
0
        public void AddSample(LuaProfiler.Sample sample)
        {
            if (_frameCount == Time.frameCount)
            {
                _gc[3]      += sample.costGC;
                frameCalls  += sample.oneFrameCall;
                currentTime += sample.costTime;
            }
            else
            {
                _gc[0]      = _gc[1];
                _gc[1]      = _gc[2];
                _gc[2]      = _gc[3];
                _gc[3]      = sample.costGC;
                frameCalls  = sample.oneFrameCall;
                currentTime = sample.costTime;
            }
            totalMemory += sample.costGC;

            totalTime     += (long)(sample.costTime * 1000000);
            totalCallTime += sample.oneFrameCall;
            averageTime    = totalTime / totalCallTime;
            for (int i = 0, imax = sample.childs.Count; i < imax; i++)
            {
                LuaProfilerTreeViewItem childItem = null;
                var sampleChild = sample.childs[i];
                if (LuaProfilerTreeView.m_nodeDict.TryGetValue(sampleChild.fullName, out childItem))
                {
                    childItem.AddSample(sampleChild);
                }
                else
                {
                    var treeItem = Create(sampleChild, depth + 1, this);
                    childs.Add(treeItem);
                }
            }
            //以下代码只不过为了 gc的显示数值不闪烁
            if (_gc[0] == _gc[1] || _gc[0] == _gc[2] || _gc[0] == _gc[3])
            {
                showGC = _gc[0];
            }
            else if (_gc[1] == _gc[2] || _gc[1] == _gc[3])
            {
                showGC = _gc[1];
            }
            else if (_gc[2] == _gc[3])
            {
                showGC = _gc[2];
            }
            else
            {
                showGC = _gc[3];
            }
            _frameCount = Time.frameCount;
        }
Ejemplo n.º 4
0
        public static LuaProfilerTreeViewItem Create(LuaProfiler.Sample sample, int depth, LuaProfilerTreeViewItem father)
        {
            var dict = LuaProfilerTreeView.m_nodeDict;

            LuaProfilerTreeViewItem mt;

            mt = objectPool.GetObject();
            mt.ResetBySample(sample, depth, father);
            dict.Add(mt.fullName, mt);

            return(mt);
        }
        private void LoadRootSample(LuaProfiler.Sample sample)
        {
            string name = sample.name;

            for (int i = 0, imax = roots.Count; i < imax; i++)
            {
                var item = roots[i];
                if (item.Compare(sample))
                {
                    item.AddSample(sample);
                    return;
                }
            }
            roots.Add(LuaProfilerTreeViewItem.Create(sample, 0, null));
        }
Ejemplo n.º 6
0
        private void LoadRootSample(LuaProfiler.Sample sample)
        {
            LuaProfilerTreeViewItem item;
            string f  = sample.fullName;
            string f1 = sample.fullName;

            if (m_nodeDict.TryGetValue(sample.fullName, out item))
            {
                item.AddSample(sample);
            }
            else
            {
                item = LuaProfilerTreeViewItem.Create(sample, 0, null);
                roots.Add(item);
            }
        }
        public void AddSample(LuaProfiler.Sample sample)
        {
            if (_frameCount == Time.frameCount)
            {
                _gc[3]      += sample.costGC;
                frameCalls  += sample.oneFrameCall;
                currentTime += sample.costTime;
            }
            else
            {
                _gc[0]      = _gc[1];
                _gc[1]      = _gc[2];
                _gc[2]      = _gc[3];
                _gc[3]      = sample.costGC;
                frameCalls  = sample.oneFrameCall;
                currentTime = sample.costTime;
            }
            totalMemory += sample.costGC;

            totalTime     += (long)(sample.costTime * 1000000);
            totalCallTime += sample.oneFrameCall;
            averageTime    = totalTime / totalCallTime;
            for (int i = 0, imax = sample.childs.Count; i < imax; i++)
            {
                childs[i].AddSample(sample.childs[i]);
            }
            //以下代码只不过为了 gc的显示数值不闪烁
            if (_gc[0] == _gc[1] || _gc[0] == _gc[2] || _gc[0] == _gc[3])
            {
                showGC = _gc[0];
            }
            else if (_gc[1] == _gc[2] || _gc[1] == _gc[3])
            {
                showGC = _gc[1];
            }
            else if (_gc[2] == _gc[3])
            {
                showGC = _gc[2];
            }
            else
            {
                showGC = _gc[3];
            }
            _frameCount = Time.frameCount;
        }
 public bool Compare(LuaProfiler.Sample sample)
 {
     if (sample == null)
     {
         return(false);
     }
     if (this.father == null && sample.fahter != null)
     {
         return(false);
     }
     if (this.father != null && sample.fahter == null)
     {
         return(false);
     }
     if (this.father != null && sample.fahter != null && this.father.displayName != sample.fahter.name)
     {
         return(false);
     }
     if (this.displayName != sample.name)
     {
         return(false);
     }
     if (this.childs.Count != sample.childs.Count)
     {
         return(false);
     }
     for (int i = 0, imax = sample.childs.Count; i < imax; i++)
     {
         var item = sample.childs[i];
         if (!this.childs[i].Compare(item))
         {
             return(false);
         }
     }
     return(true);
 }