public static LuaProfilerTreeViewItem Create(LuaProfiler.Sample sample, int depth, LuaProfilerTreeViewItem father) { LuaProfilerTreeViewItem mt = objectPool.GetObject(); mt.ResetBySample(sample, depth, father); return(mt); }
public LuaProfilerTreeView(TreeViewState treeViewState, float width) : base(treeViewState, CreateDefaultMultiColumnHeaderState(width)) { LuaProfiler.SetSampleEnd(LoadRootSample); root = LuaProfilerTreeViewItem.Create(null, -1, null); Reload(); }
public void ResetByItem(LuaProfilerTreeViewItem item, LuaProfilerTreeViewItem father) { filePath = item.filePath; m_isLua = item.m_isLua; isError = item.isError; _showMonoGC = item._showMonoGC; _showLuaGC = item._showLuaGC; totalMonoMemory = item.totalMonoMemory; totalLuaMemory = item.totalLuaMemory; selfLuaMemory = item.selfLuaMemory; selfMonoMemory = item.selfMonoMemory; selfCostTime = item.selfCostTime; totalTime = item.totalTime; displayName = item.displayName; m_originName = item.m_originName; m_originSampleId = item.m_originSampleId; fullName = item.fullName; frameCalls = item.frameCalls; currentTime = item.currentTime; totalCallTime = item.totalCallTime; averageTime = totalTime / Mathf.Max(totalCallTime, 1); childs.Clear(); this.id = item.id; depth = 0; this.father = father; }
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; }
private void SortChildren(int sortIndex, int sign, LuaProfilerTreeViewItem item) { if (item.childs != null && item.childs.Count > 0) { List <LuaProfilerTreeViewItem> rootList = item.childs; switch (sortIndex) { case 1: rootList.Sort((a, b) => { return(sign * Math.Sign(a.totalMemory - b.totalMemory)); }); break; case 2: rootList.Sort((a, b) => { return(sign * Math.Sign(a.currentTime - b.currentTime)); }); break; case 3: rootList.Sort((a, b) => { return(sign * Math.Sign(a.averageTime - b.averageTime)); }); break; case 4: rootList.Sort((a, b) => { return(sign * Math.Sign(a.totalTime - b.totalTime)); }); break; case 5: rootList.Sort((a, b) => { return(sign * Math.Sign(a.showGC - b.showGC)); }); break; case 6: rootList.Sort((a, b) => { return(sign * Math.Sign(a.totalCallTime - b.totalCallTime)); }); break; case 7: rootList.Sort((a, b) => { return(sign * Math.Sign(a.frameCalls - b.frameCalls)); }); break; } foreach (var t in rootList) { SortChildren(sortIndex, sign, t); } } }
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; }
private void LoadRootSample(Sample sample, bool needRecord) { LuaProfilerTreeViewItem item; string f = sample.fullName; m_luaMemory = sample.currentLuaMemory; if (m_nodeDict.TryGetValue(f, out item)) { item.AddSample(sample); if (needRecord) { history.Add(sample.Clone()); } } else { if (CheckSampleValid(sample)) { item = LuaProfilerTreeViewItem.Create(sample, 0, null); roots.Add(item); needRebuild = true; if (needRecord) { history.Add(sample.Clone()); } } } }
private void SortChildren(int sortIndex, LuaProfilerTreeViewItem item) { int sign = -1; if (item.childs != null && item.childs.Count > 0) { List <LuaProfilerTreeViewItem> childList = item.childs; switch (sortIndex) { case 1: childList.Sort((a, b) => { return(sign * Math.Sign(a.totalLuaMemory - b.totalLuaMemory)); }); break; case 2: childList.Sort((a, b) => { return(sign * Math.Sign(a.totalMonoMemory - b.totalMonoMemory)); }); break; case 3: childList.Sort((a, b) => { return(sign * Math.Sign(a.currentTime - b.currentTime)); }); break; case 4: childList.Sort((a, b) => { return(sign * Math.Sign(a.averageTime - b.averageTime)); }); break; case 5: childList.Sort((a, b) => { return(sign * Math.Sign(a.totalTime - b.totalTime)); }); break; case 6: childList.Sort((a, b) => { return(sign * Math.Sign(a.showLuaGC - b.showLuaGC)); }); break; case 7: childList.Sort((a, b) => { return(sign * Math.Sign(a.showMonoGC - b.showMonoGC)); }); break; case 8: childList.Sort((a, b) => { return(sign * Math.Sign(a.totalCallTime - b.totalCallTime)); }); break; case 9: childList.Sort((a, b) => { return(sign * Math.Sign(a.frameCalls - b.frameCalls)); }); break; } foreach (var t in childList) { SortChildren(sortIndex, t); } } }
private void ExpandNodeRecursive(LuaProfilerTreeViewItem t) { SetExpanded(t.id, true); foreach (var child in t.childs) { ExpandNodeRecursive(child); } }
public static LuaProfilerTreeViewItem Create(LuaProfilerTreeViewItem item, LuaProfilerTreeViewItem father) { LuaProfilerTreeViewItem mt; mt = objectPool.GetObject(); mt.ResetByItem(item, father); return(mt); }
private void LoadRootSample(Sample sample, bool needRecord, bool isHistory = false) { var instance = LuaDeepProfilerSetting.Instance; if (!isHistory) { if (instance.isRecord && !instance.isStartRecord) { return; } } LuaProfilerTreeViewItem item; string f = sample.fullName; m_luaMemory = sample.currentLuaMemory; m_monoMemory = sample.currentMonoMemory; m_pssMemory = sample.pss; m_fps = sample.fps; m_power = sample.power; //if (isHistory) //{ // m_catchLuaMemory = sample.costLuaGC; //} if (!(instance.isRecord && !instance.isStartRecord)) { historyCurve.SlotLuaMemory(sample.currentLuaMemory); historyCurve.SlotMonoMemory(sample.currentMonoMemory); historyCurve.SlotFpsMemory(sample.fps); historyCurve.SlotPssMemory(sample.pss); historyCurve.SlotPowerMemory(sample.power); } if (string.IsNullOrEmpty(sample.name)) { return; } if (instance.isRecord && !isHistory) { history.Add(sample.Clone()); } if (m_nodeDict.TryGetValue(f, out item)) { bool isAddSample = item.AddSample(sample); needRebuild = needRebuild || isAddSample; } else { item = LuaProfilerTreeViewItem.Create(sample, 0, null); roots.Add(item); needRebuild = true; } }
public LuaProfilerTreeView(TreeViewState treeViewState, float width) : base(treeViewState, CreateDefaultMultiColumnHeaderState(width)) { LuaProfiler.SetSampleEnd(LoadRootSample); m_root = LuaProfilerTreeViewItem.Create(null, -1, null); needRebuild = true; multiColumnHeader.sortingChanged += (header) => { needRebuild = true; }; history.Clear(); Reload(); }
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; }
private void AddOneNode(LuaProfilerTreeViewItem root) { treeViewItems.Add(root); if (root.children != null) { root.children.Clear(); } foreach (var item in root.childs) { AddOneNode(item); } }
public static LuaProfilerTreeViewItem Create(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 AddOneNode(LuaProfilerTreeViewItem root) { m_treeViewItems.Add(root); m_nodeDict[root.fullName] = root; if (root.children != null) { root.children.Clear(); } foreach (var item in root.childs) { AddOneNode(item); } }
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); }
public LuaProfilerTreeView(TreeViewState treeViewState, float width) : base(treeViewState, CreateDefaultMultiColumnHeaderState(width)) { //NetWorkServer.BeginListen("127.0.0.1", 23333); //NetWorkClient.ConnectServer("127.0.0.1", 23333); //LuaProfiler.SetSampleEnd(LoadRootSample); m_root = LuaProfilerTreeViewItem.Create(null, -1, null); needRebuild = true; multiColumnHeader.sortingChanged += (header) => { needRebuild = true; }; history.Clear(); EditorApplication.update -= DequeueSample; EditorApplication.update += DequeueSample; Reload(); }
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)); }
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); } }
private void LoadRootSample(Sample sample, bool needRecord, bool isHistory = false) { var instance = LuaDeepProfilerSetting.Instance; if (!isHistory) { if (instance.isRecord && !instance.isStartRecord) { return; } } LuaProfilerTreeViewItem item; string f = sample.fullName; m_luaMemory = sample.currentLuaMemory; m_monoMemory = sample.currentMonoMemory; if (!(instance.isRecord && !instance.isStartRecord)) { historyCurve.SlotLuaMemory(sample.currentLuaMemory); historyCurve.SlotMonoMemory(sample.currentMonoMemory); } if (instance.isRecord && !isHistory) { history.Add(sample.Clone()); } if (m_nodeDict.TryGetValue(f, out item)) { item.AddSample(sample); } else { item = LuaProfilerTreeViewItem.Create(sample, 0, null); roots.Add(item); needRebuild = true; } }
public void ResetBySample(Sample sample, int depth, LuaProfilerTreeViewItem father) { if (sample != null) { totalMemory = sample.costGC; _showGC = sample.costGC; totalTime = (long)(sample.costTime * 1000000); displayName = sample.name; fullName = sample.fullName; frameCalls = sample.calls; currentTime = sample.costTime; totalCallTime = sample.calls; } else { totalMemory = 0; _showGC = 0; totalTime = 0; displayName = "root"; fullName = "root"; frameCalls = 0; currentTime = 0; 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 dict = LuaProfilerTreeView.m_nodeDict; LuaProfilerTreeViewItem mt; var childSample = sample.childs[i]; if (dict.TryGetValue(childSample.fullName, out mt)) { mt.AddSample(childSample); } else { var item = Create(sample.childs[i], depth + 1, this); childs.Add(item); } } } this.father = father; rootFather = this; while (true) { if (rootFather.father == null) { break; } rootFather = rootFather.father; } _frameCount = Time.frameCount; }
//private static readonly char[] splitFun = new char[] { '&' }; public void ResetBySample(Sample sample, int depth, LuaProfilerTreeViewItem father) { if (sample != null) { filePath = sample.name.Split(splitDot, 2)[0].Trim(); int tmpLine = -1; if (int.TryParse(Regex.Match(sample.name, @"(?<=(line:))\d*(?=(&))").Value, out tmpLine)) { line = tmpLine; } else { line = -1; } _showMonoGC = sample.costMonoGC; _showLuaGC = sample.costLuaGC; totalMonoMemory = sample.costMonoGC; totalLuaMemory = sample.costLuaGC; selfLuaMemory = sample.selfLuaGC; selfMonoMemory = sample.selfMonoGC; totalTime = sample.costTime; displayName = sample.name; m_originName = sample.name; fullName = sample.fullName; frameCalls = sample.calls; currentTime = sample.costTime; totalCallTime = sample.calls; } else { _showMonoGC = 0; _showLuaGC = 0; totalMonoMemory = 0; totalLuaMemory = 0; selfMonoMemory = 0; selfLuaMemory = 0; totalTime = 0; displayName = "root"; fullName = "root"; frameCalls = 0; currentTime = 0; totalCallTime = 1; } averageTime = totalTime / Mathf.Max(totalCallTime, 1); this.id = LuaProfilerTreeView.GetUniqueId(); this.depth = depth; childs.Clear(); if (sample != null) { for (int i = 0, imax = sample.childs.Count; i < imax; i++) { var dict = LuaProfilerTreeView.m_nodeDict; LuaProfilerTreeViewItem mt; var childSample = sample.childs[i]; if (dict.TryGetValue(childSample.fullName, out mt)) { mt.AddSample(childSample); } else { var item = Create(sample.childs[i], depth + 1, this); childs.Add(item); } } _frameCount = sample.frameCount; s_frameCount = sample.frameCount; } this.father = father; }
protected override TreeViewItem BuildRoot() { if (!needRebuild) { return(m_root); } if (string.IsNullOrEmpty(m_searchString)) { ReLoadTreeItems(); // Utility method that initializes the TreeViewItem.children and -parent for all items. SetupParentsAndChildrenFromDepths(m_root, m_treeViewItems); } else { m_treeViewItems.Clear(); List <LuaProfilerTreeViewItem> rootList = new List <LuaProfilerTreeViewItem>(); AddSearchStringItem(roots, rootList); int sortIndex = multiColumnHeader.sortedColumnIndex; int sign = 0; if (sortIndex > 0) { sign = multiColumnHeader.IsSortedAscending(sortIndex) ? 1 : -1; } switch (sortIndex) { case 1: rootList.Sort((a, b) => { return(sign * Math.Sign(a.totalLuaMemory - b.totalLuaMemory)); }); break; case 2: rootList.Sort((a, b) => { return(sign * Math.Sign(a.selfLuaMemory - b.selfLuaMemory)); }); break; case 3: rootList.Sort((a, b) => { return(sign * Math.Sign(a.totalMonoMemory - b.totalMonoMemory)); }); break; case 4: rootList.Sort((a, b) => { return(sign * Math.Sign(a.selfMonoMemory - b.selfMonoMemory)); }); break; case 5: rootList.Sort((a, b) => { return(sign * Math.Sign(a.currentTime - b.currentTime)); }); break; case 6: rootList.Sort((a, b) => { return(sign * Math.Sign(a.averageTime - b.averageTime)); }); break; case 7: rootList.Sort((a, b) => { return(sign * Math.Sign(a.totalTime - b.totalTime)); }); break; case 8: rootList.Sort((a, b) => { return(sign * Math.Sign(a.showLuaGC - b.showLuaGC)); }); break; case 9: rootList.Sort((a, b) => { return(sign * Math.Sign(a.showMonoGC - b.showMonoGC)); }); break; case 10: rootList.Sort((a, b) => { return(sign * Math.Sign(a.totalCallTime - b.totalCallTime)); }); break; case 11: rootList.Sort((a, b) => { return(sign * Math.Sign(a.frameCalls - b.frameCalls)); }); break; } foreach (var item in rootList) { LuaProfilerTreeViewItem mt = LuaProfilerTreeViewItem.Create(item, m_root); m_treeViewItems.Add(mt); } SetupParentsAndChildrenFromDepths(m_root, m_treeViewItems); } needRebuild = false; // Return root of the tree return(m_root); }
public void ResetBySample(Sample sample, int depth, LuaProfilerTreeViewItem father) { if (sample != null) { filePath = sample.name.Split(splitDot, 2)[0].Trim(); int tmpLine = 0; int.TryParse(Regex.Match(sample.name, @"(?<=(line:))\d*(?=(&))").Value, out tmpLine); line = tmpLine; _showMonoGC = sample.costMonoGC; _showLuaGC = sample.costLuaGC; totalMonoMemory = sample.costMonoGC; totalLuaMemory = sample.costLuaGC; totalTime = sample.costTime; string[] tmp = sample.name.Split(splitFun, 2); if (tmp.Length >= 2) { displayName = tmp[1].Trim(); } else { displayName = sample.name; } m_originName = sample.name; fullName = sample.fullName; frameCalls = sample.calls; currentTime = sample.costTime; totalCallTime = sample.calls; } else { _showMonoGC = 0; _showLuaGC = 0; totalMonoMemory = 0; totalLuaMemory = 0; totalTime = 0; displayName = "root"; fullName = "root"; frameCalls = 0; currentTime = 0; 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 dict = LuaProfilerTreeView.m_nodeDict; LuaProfilerTreeViewItem mt; var childSample = sample.childs[i]; if (dict.TryGetValue(childSample.fullName, out mt)) { mt.AddSample(childSample); } else { if (LuaProfilerTreeView.CheckSampleValid(sample)) { var item = Create(sample.childs[i], depth + 1, this); childs.Add(item); } } } } this.father = father; rootFather = this; while (true) { if (rootFather.father == null) { break; } rootFather = rootFather.father; } _frameCount = Time.frameCount; }
protected override TreeViewItem BuildRoot() { if (!needRebuild) { return(m_root); } if (string.IsNullOrEmpty(m_searchString)) { ReLoadTreeItems(); // Utility method that initializes the TreeViewItem.children and -parent for all items. SetupParentsAndChildrenFromDepths(m_root, m_treeViewItems); } else { m_treeViewItems.Clear(); List <LuaProfilerTreeViewItem> rootList = new List <LuaProfilerTreeViewItem>(); AddSearchStringItem(roots, rootList); foreach (var item in rootList) { if (m_toggleMerge) { LuaProfilerTreeViewItem t; if (m_treeViewItemDict.TryGetValue(item.displayName, out t)) { t.AddSample(item.CopySelfToSample()); } else { LuaProfilerTreeViewItem mt = LuaProfilerTreeViewItem.Create(item, m_root); m_treeViewItemDict.Add(item.displayName, mt); m_treeViewItems.Add(mt); } } else { m_treeViewItems.Add(LuaProfilerTreeViewItem.Create(item, m_root)); } } m_treeViewItemDict.Clear(); int sortIndex = multiColumnHeader.sortedColumnIndex; int sign = 0; if (sortIndex > 0) { sign = multiColumnHeader.IsSortedAscending(sortIndex) ? 1 : -1; } switch (sortIndex) { case 1: m_treeViewItems.Sort((a, b) => { return(sign * Math.Sign(((LuaProfilerTreeViewItem)a).totalLuaMemory - ((LuaProfilerTreeViewItem)b).totalLuaMemory)); }); break; case 2: m_treeViewItems.Sort((a, b) => { return(sign * Math.Sign(((LuaProfilerTreeViewItem)a).selfLuaMemory - ((LuaProfilerTreeViewItem)b).selfLuaMemory)); }); break; case 3: m_treeViewItems.Sort((a, b) => { return(sign * Math.Sign(((LuaProfilerTreeViewItem)a).totalMonoMemory - ((LuaProfilerTreeViewItem)b).totalMonoMemory)); }); break; case 4: m_treeViewItems.Sort((a, b) => { return(sign * Math.Sign(((LuaProfilerTreeViewItem)a).selfMonoMemory - ((LuaProfilerTreeViewItem)b).selfMonoMemory)); }); break; case 5: m_treeViewItems.Sort((a, b) => { return(sign * Math.Sign(((LuaProfilerTreeViewItem)a).showLuaGC - ((LuaProfilerTreeViewItem)b).showLuaGC)); }); break; case 6: m_treeViewItems.Sort((a, b) => { return(sign * Math.Sign(((LuaProfilerTreeViewItem)a).showMonoGC - ((LuaProfilerTreeViewItem)b).showMonoGC)); }); break; case 7: m_treeViewItems.Sort((a, b) => { return(sign * Math.Sign(((LuaProfilerTreeViewItem)a).currentTime - ((LuaProfilerTreeViewItem)b).currentTime)); }); break; case 8: m_treeViewItems.Sort((a, b) => { return(sign * Math.Sign(((LuaProfilerTreeViewItem)a).selfCostTime - ((LuaProfilerTreeViewItem)b).selfCostTime)); }); break; case 9: m_treeViewItems.Sort((a, b) => { return(sign * Math.Sign(((LuaProfilerTreeViewItem)a).averageTime - ((LuaProfilerTreeViewItem)b).averageTime)); }); break; case 10: m_treeViewItems.Sort((a, b) => { return(sign * Math.Sign(((LuaProfilerTreeViewItem)a).totalTime - ((LuaProfilerTreeViewItem)b).totalTime)); }); break; case 11: m_treeViewItems.Sort((a, b) => { return(sign * Math.Sign(((LuaProfilerTreeViewItem)a).totalCallTime - ((LuaProfilerTreeViewItem)b).totalCallTime)); }); break; case 12: m_treeViewItems.Sort((a, b) => { return(sign * Math.Sign(((LuaProfilerTreeViewItem)a).frameCalls - ((LuaProfilerTreeViewItem)b).frameCalls)); }); break; } SetupParentsAndChildrenFromDepths(m_root, m_treeViewItems); } needRebuild = false; // Return root of the tree return(m_root); }
public void ResetBySample(Sample sample, int depth, LuaProfilerTreeViewItem father) { if (sample != null) { if (sample.name.Length >= 6) { m_isLua = sample.name.Substring(0, 6) == "[lua]:"; } filePath = sample.name; line = 1; if (m_isLua) { string[] array = sample.name.Split(splitDot, 2); if (array.Length == 2) { filePath = array[1]; array = filePath.Split(splitFun, 2); if (array.Length == 2) { filePath = array[0].Trim(); line = int.Parse(array[1].Split(splitLine, 2)[1]); } } } else { isError = sample.name == "exception happen clear stack"; } _showMonoGC = sample.costMonoGC; _showLuaGC = sample.costLuaGC; totalMonoMemory = sample.costMonoGC; totalLuaMemory = sample.costLuaGC; selfLuaMemory = sample.selfLuaGC; selfMonoMemory = sample.selfMonoGC; selfCostTime = sample.selfCostTime; totalTime = sample.costTime; displayName = sample.name; m_originName = sample.name; m_originSampleId = sample.sampleId; fullName = sample.fullName; frameCalls = sample.calls; currentTime = sample.costTime; totalCallTime = sample.calls; } else { _showMonoGC = 0; _showLuaGC = 0; totalMonoMemory = 0; totalLuaMemory = 0; selfMonoMemory = 0; selfLuaMemory = 0; selfCostTime = 0; totalTime = 0; displayName = "root"; fullName = "root"; frameCalls = 0; currentTime = 0; totalCallTime = 1; } averageTime = totalTime / Mathf.Max(totalCallTime, 1); this.id = LuaProfilerTreeView.GetUniqueId(); this.depth = depth; childs.Clear(); if (sample != null) { for (int i = 0, imax = sample.childs.Count; i < imax; i++) { var dict = LuaProfilerTreeView.m_nodeDict; LuaProfilerTreeViewItem mt; var childSample = sample.childs[i]; if (dict.TryGetValue(childSample.fullName, out mt)) { mt.AddSample(childSample); } else { var item = Create(sample.childs[i], depth + 1, this); childs.Add(item); } } _frameCount = sample.frameCount; } this.father = father; }