Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Unified Diff: Source/devtools/front_end/timeline/TimelineModel.js

Issue 1312563002: DevTools: [timeline tree view] fix total time calculation for recursive case. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: nodesStack -> nodesOnStack Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/inspector/tracing/timeline-js-callstacks-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/timeline/TimelineModel.js
diff --git a/Source/devtools/front_end/timeline/TimelineModel.js b/Source/devtools/front_end/timeline/TimelineModel.js
index d198d9cbebd951fbd20ac5f025eed08532cd4662..e9077775dd163524a66a0084eefacb06fa1ee15d 100644
--- a/Source/devtools/front_end/timeline/TimelineModel.js
+++ b/Source/devtools/front_end/timeline/TimelineModel.js
@@ -1552,19 +1552,23 @@ WebInspector.TimelineModel.buildBottomUpTree = function(topDownTree, groupingCal
buRoot.name = WebInspector.UIString("Bottom-Up Chart");
/** @type {!Map<string,!WebInspector.TimelineModel.ProfileTreeNode>} */
buRoot.children = new Map();
- processNode(topDownTree);
+ var nodesOnStack = /** @type {!Set<string>} */ (new Set());
+ topDownTree.children.forEach(processNode);
/**
* @param {!WebInspector.TimelineModel.ProfileTreeNode} tdNode
*/
function processNode(tdNode)
{
- if (tdNode.selfTime > 0) {
- var buParent = groupingCallback && groupingCallback(tdNode) || buRoot;
- appendNode(tdNode, buParent);
- }
+ var buParent = groupingCallback && groupingCallback(tdNode) || buRoot;
+ appendNode(tdNode, buParent);
+ var hadNode = nodesOnStack.has(tdNode.id);
+ if (!hadNode)
+ nodesOnStack.add(tdNode.id);
if (tdNode.children)
tdNode.children.forEach(processNode);
+ if (!hadNode)
+ nodesOnStack.delete(tdNode.id);
}
/**
@@ -1592,13 +1596,21 @@ WebInspector.TimelineModel.buildBottomUpTree = function(topDownTree, groupingCal
buParent.children.set(id, buNode);
} else {
buNode.selfTime += selfTime;
- buNode.totalTime += totalTime;
+ if (!nodesOnStack.has(id))
+ buNode.totalTime += totalTime;
}
tdNode = tdNode.parent;
buParent = buNode;
}
}
+ // Purge zero self time nodes.
+ var rootChildren = buRoot.children;
+ for (var item of rootChildren.entries()) {
+ if (item[1].selfTime === 0)
+ rootChildren.delete(item[0]);
+ }
+
return buRoot;
}
« no previous file with comments | « LayoutTests/inspector/tracing/timeline-js-callstacks-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698