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} node | 8 * @param {!ProfilerAgent.CPUProfileNode} node |
9 * @param {number} sampleTime | 9 * @param {number} sampleTime |
10 */ | 10 */ |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 var keepNatives = !!WebInspector.moduleSetting("showNativeFunctionsInJSP
rofile").get(); | 105 var keepNatives = !!WebInspector.moduleSetting("showNativeFunctionsInJSP
rofile").get(); |
106 var root = nodes[0]; | 106 var root = nodes[0]; |
107 /** @type {!Map<number, number>} */ | 107 /** @type {!Map<number, number>} */ |
108 var idMap = new Map([[root.id, root.id]]); | 108 var idMap = new Map([[root.id, root.id]]); |
109 var resultRoot = new WebInspector.CPUProfileNode(root, sampleTime); | 109 var resultRoot = new WebInspector.CPUProfileNode(root, sampleTime); |
110 var parentNodeStack = root.children.map(() => resultRoot); | 110 var parentNodeStack = root.children.map(() => resultRoot); |
111 var sourceNodeStack = root.children.map(id => nodeByIdMap.get(id)); | 111 var sourceNodeStack = root.children.map(id => nodeByIdMap.get(id)); |
112 while (sourceNodeStack.length) { | 112 while (sourceNodeStack.length) { |
113 var parentNode = parentNodeStack.pop(); | 113 var parentNode = parentNodeStack.pop(); |
114 var sourceNode = sourceNodeStack.pop(); | 114 var sourceNode = sourceNodeStack.pop(); |
| 115 if (!sourceNode.children) |
| 116 sourceNode.children = []; |
115 var targetNode = new WebInspector.CPUProfileNode(sourceNode, sampleT
ime); | 117 var targetNode = new WebInspector.CPUProfileNode(sourceNode, sampleT
ime); |
116 if (keepNatives || !isNativeNode(sourceNode)) { | 118 if (keepNatives || !isNativeNode(sourceNode)) { |
117 parentNode.children.push(targetNode); | 119 parentNode.children.push(targetNode); |
118 parentNode = targetNode; | 120 parentNode = targetNode; |
119 } else { | 121 } else { |
120 parentNode.self += targetNode.self; | 122 parentNode.self += targetNode.self; |
121 } | 123 } |
122 idMap.set(sourceNode.id, parentNode.id); | 124 idMap.set(sourceNode.id, parentNode.id); |
123 parentNodeStack.push.apply(parentNodeStack, sourceNode.children.map(
() => parentNode)); | 125 parentNodeStack.push.apply(parentNodeStack, sourceNode.children.map(
() => parentNode)); |
124 sourceNodeStack.push.apply(sourceNodeStack, sourceNode.children.map(
id => nodeByIdMap.get(id))); | 126 sourceNodeStack.push.apply(sourceNodeStack, sourceNode.children.map(
id => nodeByIdMap.get(id))); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 * @param {number} index | 324 * @param {number} index |
323 * @return {?WebInspector.CPUProfileNode} | 325 * @return {?WebInspector.CPUProfileNode} |
324 */ | 326 */ |
325 nodeByIndex: function(index) | 327 nodeByIndex: function(index) |
326 { | 328 { |
327 return this._idToNode.get(this.samples[index]) || null; | 329 return this._idToNode.get(this.samples[index]) || null; |
328 }, | 330 }, |
329 | 331 |
330 __proto__: WebInspector.ProfileTreeModel.prototype | 332 __proto__: WebInspector.ProfileTreeModel.prototype |
331 } | 333 } |
OLD | NEW |