Пример #1
0
        public void AddSample(Sample sample)
        {
            if (_frameCount == sample.frameCount)
            {
                _showGC     += sample.costGC;
                frameCalls  += sample.calls;
                currentTime += sample.costTime;
            }
            else
            {
                _showGC     = sample.costGC;
                frameCalls  = sample.calls;
                currentTime = sample.costTime;
            }
            totalMemory += sample.costGC;

            totalTime     += (long)(sample.costTime * 1000000);
            totalCallTime += sample.calls;
            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);
                }
            }
            _frameCount = Time.frameCount;
        }
Пример #2
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;
        }
        public bool AddSample(Sample sample)
        {
            bool result = false;

            if (_frameCount == sample.frameCount)
            {
                frameCalls   += sample.calls;
                currentTime  += sample.costTime;
                _showMonoGC  += Math.Max(sample.costMonoGC, 0);
                _showLuaGC   += Math.Max(sample.costLuaGC, 0);
                selfCostTime += sample.selfCostTime;
            }
            else
            {
                frameCalls   = sample.calls;
                currentTime  = sample.costTime;
                _showMonoGC  = sample.costMonoGC;
                _showLuaGC   = sample.costLuaGC;
                selfCostTime = sample.selfCostTime;
            }

            totalLuaMemory  += Math.Max(sample.costLuaGC, 0);
            selfLuaMemory   += Math.Max(sample.selfLuaGC, 0);
            totalMonoMemory += Math.Max(sample.costMonoGC, 0);
            selfMonoMemory  += Math.Max(sample.selfMonoGC, 0);

            totalTime     += sample.costTime;
            totalCallTime += sample.calls;
            averageTime    = totalTime / Mathf.Max(totalCallTime, 1);
            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
                {
                    result = true;
                    var treeItem = Create(sampleChild, depth + 1, this);
                    childs.Add(treeItem);
                }
            }
            _frameCount  = sample.frameCount;
            s_frameCount = sample.frameCount;

            return(result);
        }