| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * @param {!RuntimeAgent.CallFrame} callFrame | 7 * @param {!RuntimeAgent.CallFrame} callFrame |
| 8 */ | 8 */ |
| 9 WebInspector.ProfileNode = function(callFrame) | 9 WebInspector.ProfileNode = function(callFrame) |
| 10 { | 10 { |
| 11 /** @type {!RuntimeAgent.CallFrame} */ | 11 /** @type {!RuntimeAgent.CallFrame} */ |
| 12 this.callFrame = callFrame; | 12 this.callFrame = callFrame; |
| 13 /** @type {string} */ | 13 /** @type {string} */ |
| 14 this.callUID = `${this.callFrame.functionName}@${this.callFrame.scriptId}:${
this.callFrame.lineNumber}`; | 14 this.callUID = `${this.callFrame.functionName}@${this.callFrame.scriptId}:${
this.callFrame.lineNumber}`; |
| 15 /** @type {number} */ | 15 /** @type {number} */ |
| 16 this.self = 0; | 16 this.self = 0; |
| 17 /** @type {number} */ | 17 /** @type {number} */ |
| 18 this.total = 0; | 18 this.total = 0; |
| 19 /** @type {number} */ | 19 /** @type {number} */ |
| 20 this.id = 0; | 20 this.id = 0; |
| 21 /** @type {?WebInspector.ProfileNode} */ | 21 /** @type {?WebInspector.ProfileNode} */ |
| 22 this.parent = null; | 22 this.parent = null; |
| 23 /** @type {!Array<!WebInspector.ProfileNode>} */ | 23 /** @type {!Array<!WebInspector.ProfileNode>} */ |
| 24 this.children = []; | 24 this.children = []; |
| 25 } | 25 }; |
| 26 | 26 |
| 27 WebInspector.ProfileNode.prototype = { | 27 WebInspector.ProfileNode.prototype = { |
| 28 /** | 28 /** |
| 29 * @return {string} | 29 * @return {string} |
| 30 */ | 30 */ |
| 31 get functionName() | 31 get functionName() |
| 32 { | 32 { |
| 33 return this.callFrame.functionName; | 33 return this.callFrame.functionName; |
| 34 }, | 34 }, |
| 35 | 35 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 57 return this.callFrame.lineNumber; | 57 return this.callFrame.lineNumber; |
| 58 }, | 58 }, |
| 59 | 59 |
| 60 /** | 60 /** |
| 61 * @return {number} | 61 * @return {number} |
| 62 */ | 62 */ |
| 63 get columnNumber() | 63 get columnNumber() |
| 64 { | 64 { |
| 65 return this.callFrame.columnNumber; | 65 return this.callFrame.columnNumber; |
| 66 } | 66 } |
| 67 } | 67 }; |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * @constructor | 70 * @constructor |
| 71 * @param {!WebInspector.ProfileNode} root | 71 * @param {!WebInspector.ProfileNode} root |
| 72 */ | 72 */ |
| 73 WebInspector.ProfileTreeModel = function(root) | 73 WebInspector.ProfileTreeModel = function(root) |
| 74 { | 74 { |
| 75 this.root = root; | 75 this.root = root; |
| 76 this._assignDepthsAndParents(); | 76 this._assignDepthsAndParents(); |
| 77 this.total = this._calculateTotals(this.root); | 77 this.total = this._calculateTotals(this.root); |
| 78 } | 78 }; |
| 79 | 79 |
| 80 WebInspector.ProfileTreeModel.prototype = { | 80 WebInspector.ProfileTreeModel.prototype = { |
| 81 _assignDepthsAndParents: function() | 81 _assignDepthsAndParents: function() |
| 82 { | 82 { |
| 83 var root = this.root; | 83 var root = this.root; |
| 84 root.depth = -1; | 84 root.depth = -1; |
| 85 root.parent = null; | 85 root.parent = null; |
| 86 this.maxDepth = 0; | 86 this.maxDepth = 0; |
| 87 var nodesToTraverse = [root]; | 87 var nodesToTraverse = [root]; |
| 88 while (nodesToTraverse.length) { | 88 while (nodesToTraverse.length) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 115 node.total = node.self; | 115 node.total = node.self; |
| 116 dfsList.push(node); | 116 dfsList.push(node); |
| 117 nodesToTraverse.push(...node.children); | 117 nodesToTraverse.push(...node.children); |
| 118 } | 118 } |
| 119 while (dfsList.length > 1) { | 119 while (dfsList.length > 1) { |
| 120 var node = dfsList.pop(); | 120 var node = dfsList.pop(); |
| 121 node.parent.total += node.total; | 121 node.parent.total += node.total; |
| 122 } | 122 } |
| 123 return root.total; | 123 return root.total; |
| 124 } | 124 } |
| 125 } | 125 }; |
| OLD | NEW |