| 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.ProfileNode} node | 8 * @param {!ProfilerAgent.ProfileNode} node |
| 9 * @param {number} sampleTime | 9 * @param {number} sampleTime |
| 10 */ | 10 */ |
| 11 WebInspector.CPUProfileNode = function(node, sampleTime) | 11 WebInspector.CPUProfileNode = function(node, sampleTime) |
| 12 { | 12 { |
| 13 var callFrame = node.callFrame || /** @type {!RuntimeAgent.CallFrame} */ ({ | 13 var callFrame = node.callFrame || /** @type {!RuntimeAgent.CallFrame} */ ({ |
| 14 // Backward compatibility for old SamplingHeapProfileNode format. | 14 // Backward compatibility for old SamplingHeapProfileNode format. |
| 15 functionName: node["functionName"], | 15 functionName: node["functionName"], |
| 16 scriptId: node["scriptId"], | 16 scriptId: node["scriptId"], |
| 17 url: node["url"], | 17 url: node["url"], |
| 18 lineNumber: node["lineNumber"] - 1, | 18 lineNumber: node["lineNumber"] - 1, |
| 19 columnNumber: node["columnNumber"] - 1 | 19 columnNumber: node["columnNumber"] - 1 |
| 20 }); | 20 }); |
| 21 WebInspector.ProfileNode.call(this, callFrame); | 21 WebInspector.ProfileNode.call(this, callFrame); |
| 22 this.id = node.id; | 22 this.id = node.id; |
| 23 this.self = node.hitCount * sampleTime; | 23 this.self = node.hitCount * sampleTime; |
| 24 this.positionTicks = node.positionTicks; | 24 this.positionTicks = node.positionTicks; |
| 25 // Compatibility: legacy backends could provide "no reason" for optimized fu
nctions. | 25 // Compatibility: legacy backends could provide "no reason" for optimized fu
nctions. |
| 26 this.deoptReason = node.deoptReason && node.deoptReason !== "no reason" ? no
de.deoptReason : null; | 26 this.deoptReason = node.deoptReason && node.deoptReason !== "no reason" ? no
de.deoptReason : null; |
| 27 } | 27 }; |
| 28 | 28 |
| 29 WebInspector.CPUProfileNode.prototype = { | 29 WebInspector.CPUProfileNode.prototype = { |
| 30 __proto__: WebInspector.ProfileNode.prototype | 30 __proto__: WebInspector.ProfileNode.prototype |
| 31 } | 31 }; |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * @constructor | 34 * @constructor |
| 35 * @extends {WebInspector.ProfileTreeModel} | 35 * @extends {WebInspector.ProfileTreeModel} |
| 36 * @param {!ProfilerAgent.Profile} profile | 36 * @param {!ProfilerAgent.Profile} profile |
| 37 */ | 37 */ |
| 38 WebInspector.CPUProfileDataModel = function(profile) | 38 WebInspector.CPUProfileDataModel = function(profile) |
| 39 { | 39 { |
| 40 var isLegacyFormat = !!profile["head"]; | 40 var isLegacyFormat = !!profile["head"]; |
| 41 if (isLegacyFormat) { | 41 if (isLegacyFormat) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 53 this.samples = profile.samples; | 53 this.samples = profile.samples; |
| 54 this.totalHitCount = 0; | 54 this.totalHitCount = 0; |
| 55 this.profileHead = this._translateProfileTree(profile.nodes); | 55 this.profileHead = this._translateProfileTree(profile.nodes); |
| 56 WebInspector.ProfileTreeModel.call(this, this.profileHead); | 56 WebInspector.ProfileTreeModel.call(this, this.profileHead); |
| 57 this._extractMetaNodes(); | 57 this._extractMetaNodes(); |
| 58 if (this.samples) { | 58 if (this.samples) { |
| 59 this._buildIdToNodeMap(); | 59 this._buildIdToNodeMap(); |
| 60 this._sortSamples(); | 60 this._sortSamples(); |
| 61 this._normalizeTimestamps(); | 61 this._normalizeTimestamps(); |
| 62 } | 62 } |
| 63 } | 63 }; |
| 64 | 64 |
| 65 WebInspector.CPUProfileDataModel.prototype = { | 65 WebInspector.CPUProfileDataModel.prototype = { |
| 66 /** | 66 /** |
| 67 * @param {!ProfilerAgent.Profile} profile | 67 * @param {!ProfilerAgent.Profile} profile |
| 68 */ | 68 */ |
| 69 _compatibilityConversionHeadToNodes: function(profile) | 69 _compatibilityConversionHeadToNodes: function(profile) |
| 70 { | 70 { |
| 71 if (!profile.head || profile.nodes) | 71 if (!profile.head || profile.nodes) |
| 72 return; | 72 return; |
| 73 /** @type {!Array<!ProfilerAgent.ProfileNode>} */ | 73 /** @type {!Array<!ProfilerAgent.ProfileNode>} */ |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 /** | 367 /** |
| 368 * @param {number} index | 368 * @param {number} index |
| 369 * @return {?WebInspector.CPUProfileNode} | 369 * @return {?WebInspector.CPUProfileNode} |
| 370 */ | 370 */ |
| 371 nodeByIndex: function(index) | 371 nodeByIndex: function(index) |
| 372 { | 372 { |
| 373 return this._idToNode.get(this.samples[index]) || null; | 373 return this._idToNode.get(this.samples[index]) || null; |
| 374 }, | 374 }, |
| 375 | 375 |
| 376 __proto__: WebInspector.ProfileTreeModel.prototype | 376 __proto__: WebInspector.ProfileTreeModel.prototype |
| 377 } | 377 }; |
| OLD | NEW |