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

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

Issue 2150803002: [DevTools] Add callFrame to CPUProfileNode & SamplingHeapProfileNode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @extends {WebInspector.ProfileNode} 7 * @extends {WebInspector.ProfileNode}
8 * @param {!ProfilerAgent.CPUProfileNode} sourceNode 8 * @param {!ProfilerAgent.CPUProfileNode} sourceNode
9 * @param {number} sampleTime 9 * @param {number} sampleTime
10 */ 10 */
11 WebInspector.CPUProfileNode = function(sourceNode, sampleTime) 11 WebInspector.CPUProfileNode = function(sourceNode, sampleTime)
12 { 12 {
13 WebInspector.ProfileNode.call(this, sourceNode.functionName, sourceNode.scri ptId, sourceNode.url, sourceNode.lineNumber, sourceNode.columnNumber); 13 if (sourceNode.callFrame) {
14 WebInspector.ProfileNode.call(this, sourceNode.callFrame);
15 } else {
16 // Backward compatibility for old CPUProfileNode format.
17 var frame = /** @type {!RuntimeAgent.CallFrame} */(sourceNode);
18 WebInspector.ProfileNode.call(this, {
19 functionName: frame.functionName,
20 scriptId: frame.scriptId, url: frame.url,
21 lineNumber: frame.lineNumber - 1,
22 columnNumber: frame.columnNumber - 1
23 });
24 }
14 this.id = sourceNode.id; 25 this.id = sourceNode.id;
15 this.self = sourceNode.hitCount * sampleTime; 26 this.self = sourceNode.hitCount * sampleTime;
16 this.positionTicks = sourceNode.positionTicks; 27 this.positionTicks = sourceNode.positionTicks;
17 this.deoptReason = sourceNode.deoptReason; 28 this.deoptReason = sourceNode.deoptReason;
18 } 29 }
19 30
20 WebInspector.CPUProfileNode.prototype = { 31 WebInspector.CPUProfileNode.prototype = {
21 __proto__: WebInspector.ProfileNode.prototype 32 __proto__: WebInspector.ProfileNode.prototype
22 } 33 }
23 34
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 function computeHitCountForSubtree(node) 69 function computeHitCountForSubtree(node)
59 { 70 {
60 return node.children.reduce((acc, node) => acc + computeHitCountForS ubtree(node), node.hitCount); 71 return node.children.reduce((acc, node) => acc + computeHitCountForS ubtree(node), node.hitCount);
61 } 72 }
62 /** 73 /**
63 * @param {!ProfilerAgent.CPUProfileNode} node 74 * @param {!ProfilerAgent.CPUProfileNode} node
64 * @return {boolean} 75 * @return {boolean}
65 */ 76 */
66 function isNativeNode(node) 77 function isNativeNode(node)
67 { 78 {
79 if (node.callFrame)
80 return !!node.callFrame.url && node.callFrame.url.startsWith("na tive ");
68 return !!node.url && node.url.startsWith("native "); 81 return !!node.url && node.url.startsWith("native ");
69 } 82 }
70 this.totalHitCount = computeHitCountForSubtree(root); 83 this.totalHitCount = computeHitCountForSubtree(root);
71 var sampleTime = (this.profileEndTime - this.profileStartTime) / this.to talHitCount; 84 var sampleTime = (this.profileEndTime - this.profileStartTime) / this.to talHitCount;
72 var keepNatives = !!WebInspector.moduleSetting("showNativeFunctionsInJSP rofile").get(); 85 var keepNatives = !!WebInspector.moduleSetting("showNativeFunctionsInJSP rofile").get();
73 /** @type {!Map<number, number>} */ 86 /** @type {!Map<number, number>} */
74 var idMap = new Map([[root.id, root.id]]); 87 var idMap = new Map([[root.id, root.id]]);
75 var resultRoot = new WebInspector.CPUProfileNode(root, sampleTime); 88 var resultRoot = new WebInspector.CPUProfileNode(root, sampleTime);
76 var parentNodeStack = root.children.map(() => resultRoot); 89 var parentNodeStack = root.children.map(() => resultRoot);
77 var sourceNodeStack = root.children; 90 var sourceNodeStack = root.children;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 * @param {number} index 301 * @param {number} index
289 * @return {?WebInspector.CPUProfileNode} 302 * @return {?WebInspector.CPUProfileNode}
290 */ 303 */
291 nodeByIndex: function(index) 304 nodeByIndex: function(index)
292 { 305 {
293 return this._idToNode.get(this.samples[index]) || null; 306 return this._idToNode.get(this.samples[index]) || null;
294 }, 307 },
295 308
296 __proto__: WebInspector.ProfileTreeModel.prototype 309 __proto__: WebInspector.ProfileTreeModel.prototype
297 } 310 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698