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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js

Issue 2321163003: DevTools: Support profile trees encoded with parents rather than children. (Closed)
Patch Set: Created 4 years, 3 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 | « third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-bottom-up-times.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js
index 6eea7504619b5b53ea215898a41eeced4850651f..1e4dafcc2d164f38658bfa78154a84cc71497363 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js
@@ -120,12 +120,30 @@ WebInspector.CPUProfileDataModel.prototype = {
return !!node.callFrame.url && node.callFrame.url.startsWith("native ");
return !!node.url && node.url.startsWith("native ");
}
+ /**
+ * @param {!Array<!ProfilerAgent.ProfileNode>} nodes
+ */
+ function buildChildrenFromParents(nodes)
+ {
+ if (nodes[0].children)
+ return;
+ nodes[0].children = [];
+ for (var i = 1; i < nodes.length; ++i) {
+ var node = nodes[i];
+ var parentNode = nodeByIdMap.get(node.parent);
+ if (parentNode.children)
+ parentNode.children.push(node.id);
+ else
+ parentNode.children = [node.id];
+ }
+ }
/** @type {!Map<number, !ProfilerAgent.ProfileNode>} */
var nodeByIdMap = new Map();
for (var i = 0; i < nodes.length; ++i) {
var node = nodes[i];
nodeByIdMap.set(node.id, node);
}
+ buildChildrenFromParents(nodes);
this.totalHitCount = nodes.reduce((acc, node) => acc + node.hitCount, 0);
var sampleTime = (this.profileEndTime - this.profileStartTime) / this.totalHitCount;
var keepNatives = !!WebInspector.moduleSetting("showNativeFunctionsInJSProfile").get();
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-bottom-up-times.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698