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} node | 8 * @param {!ProfilerAgent.CPUProfileNode} node |
| 9 * @param {number} sampleTime | 9 * @param {number} sampleTime |
| 10 */ | 10 */ |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 * @param {!ProfilerAgent.CPUProfile} profile | 35 * @param {!ProfilerAgent.CPUProfile} profile |
| 36 */ | 36 */ |
| 37 WebInspector.CPUProfileDataModel = function(profile) | 37 WebInspector.CPUProfileDataModel = function(profile) |
| 38 { | 38 { |
| 39 this.samples = profile.samples; | 39 this.samples = profile.samples; |
| 40 this.timestamps = profile.timestamps; | 40 this.timestamps = profile.timestamps; |
| 41 // Convert times from sec to msec. | 41 // Convert times from sec to msec. |
| 42 this.profileStartTime = profile.startTime * 1000; | 42 this.profileStartTime = profile.startTime * 1000; |
| 43 this.profileEndTime = profile.endTime * 1000; | 43 this.profileEndTime = profile.endTime * 1000; |
| 44 this.totalHitCount = 0; | 44 this.totalHitCount = 0; |
| 45 this._compatibilityConversionHeadToNodes(profile); | |
| 45 this.profileHead = this._translateProfileTree(profile.nodes); | 46 this.profileHead = this._translateProfileTree(profile.nodes); |
| 46 WebInspector.ProfileTreeModel.call(this, this.profileHead); | 47 WebInspector.ProfileTreeModel.call(this, this.profileHead); |
| 47 this._extractMetaNodes(); | 48 this._extractMetaNodes(); |
| 48 if (this.samples) { | 49 if (this.samples) { |
| 49 this._buildIdToNodeMap(); | 50 this._buildIdToNodeMap(); |
| 50 this._sortSamples(); | 51 this._sortSamples(); |
| 51 this._normalizeTimestamps(); | 52 this._normalizeTimestamps(); |
| 52 } | 53 } |
| 53 } | 54 } |
| 54 | 55 |
| 55 WebInspector.CPUProfileDataModel.prototype = { | 56 WebInspector.CPUProfileDataModel.prototype = { |
| 56 /** | 57 /** |
| 58 * @param {!ProfilerAgent.CPUProfile} profile | |
| 59 */ | |
| 60 _compatibilityConversionHeadToNodes: function(profile) | |
| 61 { | |
| 62 if (!profile.head || profile.nodes) | |
| 63 return; | |
| 64 /** @type {!Array<!ProfilerAgent.CPUProfileNode>} */ | |
| 65 var nodes = []; | |
| 66 convertNodesTree(profile.head); | |
| 67 profile.nodes = nodes; | |
| 68 profile.head = null; | |
|
dgozman
2016/08/18 01:55:15
Maybe delete profile.head?
alph
2016/08/18 05:22:48
Assigning null seems to be better from v8 performa
dgozman
2016/08/18 05:30:31
Sure, but assigning null makes profile not conform
| |
| 69 /** | |
| 70 * @param {!ProfilerAgent.CPUProfileNode} node | |
| 71 * @return {number} | |
| 72 */ | |
| 73 function convertNodesTree(node) | |
| 74 { | |
| 75 nodes.push(node); | |
| 76 node.children = (/** @type {!Array<!ProfilerAgent.CPUProfileNode>} * /(node.children)).map(convertNodesTree); | |
| 77 return node.id; | |
| 78 } | |
| 79 }, | |
| 80 | |
| 81 /** | |
| 57 * @param {!Array<!ProfilerAgent.CPUProfileNode>} nodes | 82 * @param {!Array<!ProfilerAgent.CPUProfileNode>} nodes |
| 58 * @return {!WebInspector.CPUProfileNode} | 83 * @return {!WebInspector.CPUProfileNode} |
| 59 */ | 84 */ |
| 60 _translateProfileTree: function(nodes) | 85 _translateProfileTree: function(nodes) |
| 61 { | 86 { |
| 62 /** | 87 /** |
| 63 * @param {!ProfilerAgent.CPUProfileNode} node | 88 * @param {!ProfilerAgent.CPUProfileNode} node |
| 64 * @return {boolean} | 89 * @return {boolean} |
| 65 */ | 90 */ |
| 66 function isNativeNode(node) | 91 function isNativeNode(node) |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 * @param {number} index | 322 * @param {number} index |
| 298 * @return {?WebInspector.CPUProfileNode} | 323 * @return {?WebInspector.CPUProfileNode} |
| 299 */ | 324 */ |
| 300 nodeByIndex: function(index) | 325 nodeByIndex: function(index) |
| 301 { | 326 { |
| 302 return this._idToNode.get(this.samples[index]) || null; | 327 return this._idToNode.get(this.samples[index]) || null; |
| 303 }, | 328 }, |
| 304 | 329 |
| 305 __proto__: WebInspector.ProfileTreeModel.prototype | 330 __proto__: WebInspector.ProfileTreeModel.prototype |
| 306 } | 331 } |
| OLD | NEW |