Chromium Code Reviews| OLD | NEW |
|---|---|
| 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, { functionName: frame.functionName, scriptId: frame.scriptId, url: frame.url, lineNumber: frame.lineNumber - 1, colu mnNumber: frame.columnNumber - 1}); | |
|
alph
2016/07/14 21:53:29
ditto
kozy
2016/07/15 00:19:02
Done.
| |
| 19 } | |
| 14 this.id = sourceNode.id; | 20 this.id = sourceNode.id; |
| 15 this.self = sourceNode.hitCount * sampleTime; | 21 this.self = sourceNode.hitCount * sampleTime; |
| 16 this.callUID = sourceNode.callUID; | 22 this.callUID = sourceNode.callUID; |
| 17 this.positionTicks = sourceNode.positionTicks; | 23 this.positionTicks = sourceNode.positionTicks; |
| 18 this.deoptReason = sourceNode.deoptReason; | 24 this.deoptReason = sourceNode.deoptReason; |
| 19 } | 25 } |
| 20 | 26 |
| 21 WebInspector.CPUProfileNode.prototype = { | 27 WebInspector.CPUProfileNode.prototype = { |
| 22 __proto__: WebInspector.ProfileNode.prototype | 28 __proto__: WebInspector.ProfileNode.prototype |
| 23 } | 29 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 function computeHitCountForSubtree(node) | 65 function computeHitCountForSubtree(node) |
| 60 { | 66 { |
| 61 return node.children.reduce((acc, node) => acc + computeHitCountForS ubtree(node), node.hitCount); | 67 return node.children.reduce((acc, node) => acc + computeHitCountForS ubtree(node), node.hitCount); |
| 62 } | 68 } |
| 63 /** | 69 /** |
| 64 * @param {!ProfilerAgent.CPUProfileNode} node | 70 * @param {!ProfilerAgent.CPUProfileNode} node |
| 65 * @return {boolean} | 71 * @return {boolean} |
| 66 */ | 72 */ |
| 67 function isNativeNode(node) | 73 function isNativeNode(node) |
| 68 { | 74 { |
| 75 if (node.callFrame) | |
| 76 return !!node.callFrame.url && node.callFrame.url.startsWith("na tive "); | |
| 69 return !!node.url && node.url.startsWith("native "); | 77 return !!node.url && node.url.startsWith("native "); |
| 70 } | 78 } |
| 71 this.totalHitCount = computeHitCountForSubtree(root); | 79 this.totalHitCount = computeHitCountForSubtree(root); |
| 72 var sampleTime = (this.profileEndTime - this.profileStartTime) / this.to talHitCount; | 80 var sampleTime = (this.profileEndTime - this.profileStartTime) / this.to talHitCount; |
| 73 var keepNatives = !!WebInspector.moduleSetting("showNativeFunctionsInJSP rofile").get(); | 81 var keepNatives = !!WebInspector.moduleSetting("showNativeFunctionsInJSP rofile").get(); |
| 74 /** @type {!Map<number, number>} */ | 82 /** @type {!Map<number, number>} */ |
| 75 var idMap = new Map([[root.id, root.id]]); | 83 var idMap = new Map([[root.id, root.id]]); |
| 76 var resultRoot = new WebInspector.CPUProfileNode(root, sampleTime); | 84 var resultRoot = new WebInspector.CPUProfileNode(root, sampleTime); |
| 77 var parentNodeStack = root.children.map(() => resultRoot); | 85 var parentNodeStack = root.children.map(() => resultRoot); |
| 78 var sourceNodeStack = root.children; | 86 var sourceNodeStack = root.children; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 * @param {number} index | 297 * @param {number} index |
| 290 * @return {?WebInspector.CPUProfileNode} | 298 * @return {?WebInspector.CPUProfileNode} |
| 291 */ | 299 */ |
| 292 nodeByIndex: function(index) | 300 nodeByIndex: function(index) |
| 293 { | 301 { |
| 294 return this._idToNode.get(this.samples[index]) || null; | 302 return this._idToNode.get(this.samples[index]) || null; |
| 295 }, | 303 }, |
| 296 | 304 |
| 297 __proto__: WebInspector.ProfileTreeModel.prototype | 305 __proto__: WebInspector.ProfileTreeModel.prototype |
| 298 } | 306 } |
| OLD | NEW |