| 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 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 WebInspector.ProfileNode = class { | 7 SDK.ProfileNode = class { |
| 8 /** | 8 /** |
| 9 * @param {!Protocol.Runtime.CallFrame} callFrame | 9 * @param {!Protocol.Runtime.CallFrame} callFrame |
| 10 */ | 10 */ |
| 11 constructor(callFrame) { | 11 constructor(callFrame) { |
| 12 /** @type {!Protocol.Runtime.CallFrame} */ | 12 /** @type {!Protocol.Runtime.CallFrame} */ |
| 13 this.callFrame = callFrame; | 13 this.callFrame = callFrame; |
| 14 /** @type {string} */ | 14 /** @type {string} */ |
| 15 this.callUID = `${this.callFrame.functionName}@${this.callFrame.scriptId}:${
this.callFrame.lineNumber}`; | 15 this.callUID = `${this.callFrame.functionName}@${this.callFrame.scriptId}:${
this.callFrame.lineNumber}`; |
| 16 /** @type {number} */ | 16 /** @type {number} */ |
| 17 this.self = 0; | 17 this.self = 0; |
| 18 /** @type {number} */ | 18 /** @type {number} */ |
| 19 this.total = 0; | 19 this.total = 0; |
| 20 /** @type {number} */ | 20 /** @type {number} */ |
| 21 this.id = 0; | 21 this.id = 0; |
| 22 /** @type {?WebInspector.ProfileNode} */ | 22 /** @type {?SDK.ProfileNode} */ |
| 23 this.parent = null; | 23 this.parent = null; |
| 24 /** @type {!Array<!WebInspector.ProfileNode>} */ | 24 /** @type {!Array<!SDK.ProfileNode>} */ |
| 25 this.children = []; | 25 this.children = []; |
| 26 } | 26 } |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * @return {string} | 29 * @return {string} |
| 30 */ | 30 */ |
| 31 get functionName() { | 31 get functionName() { |
| 32 return this.callFrame.functionName; | 32 return this.callFrame.functionName; |
| 33 } | 33 } |
| 34 | 34 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 57 * @return {number} | 57 * @return {number} |
| 58 */ | 58 */ |
| 59 get columnNumber() { | 59 get columnNumber() { |
| 60 return this.callFrame.columnNumber; | 60 return this.callFrame.columnNumber; |
| 61 } | 61 } |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * @unrestricted | 65 * @unrestricted |
| 66 */ | 66 */ |
| 67 WebInspector.ProfileTreeModel = class { | 67 SDK.ProfileTreeModel = class { |
| 68 /** | 68 /** |
| 69 * @param {!WebInspector.ProfileNode} root | 69 * @param {!SDK.ProfileNode} root |
| 70 * @protected | 70 * @protected |
| 71 */ | 71 */ |
| 72 initialize(root) { | 72 initialize(root) { |
| 73 this.root = root; | 73 this.root = root; |
| 74 this._assignDepthsAndParents(); | 74 this._assignDepthsAndParents(); |
| 75 this.total = this._calculateTotals(this.root); | 75 this.total = this._calculateTotals(this.root); |
| 76 } | 76 } |
| 77 | 77 |
| 78 _assignDepthsAndParents() { | 78 _assignDepthsAndParents() { |
| 79 var root = this.root; | 79 var root = this.root; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 92 var child = children[i]; | 92 var child = children[i]; |
| 93 child.depth = depth; | 93 child.depth = depth; |
| 94 child.parent = parent; | 94 child.parent = parent; |
| 95 if (child.children.length) | 95 if (child.children.length) |
| 96 nodesToTraverse.push(child); | 96 nodesToTraverse.push(child); |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 | 100 |
| 101 /** | 101 /** |
| 102 * @param {!WebInspector.ProfileNode} root | 102 * @param {!SDK.ProfileNode} root |
| 103 * @return {number} | 103 * @return {number} |
| 104 */ | 104 */ |
| 105 _calculateTotals(root) { | 105 _calculateTotals(root) { |
| 106 var nodesToTraverse = [root]; | 106 var nodesToTraverse = [root]; |
| 107 var dfsList = []; | 107 var dfsList = []; |
| 108 while (nodesToTraverse.length) { | 108 while (nodesToTraverse.length) { |
| 109 var node = nodesToTraverse.pop(); | 109 var node = nodesToTraverse.pop(); |
| 110 node.total = node.self; | 110 node.total = node.self; |
| 111 dfsList.push(node); | 111 dfsList.push(node); |
| 112 nodesToTraverse.push(...node.children); | 112 nodesToTraverse.push(...node.children); |
| 113 } | 113 } |
| 114 while (dfsList.length > 1) { | 114 while (dfsList.length > 1) { |
| 115 var node = dfsList.pop(); | 115 var node = dfsList.pop(); |
| 116 node.parent.total += node.total; | 116 node.parent.total += node.total; |
| 117 } | 117 } |
| 118 return root.total; | 118 return root.total; |
| 119 } | 119 } |
| 120 }; | 120 }; |
| OLD | NEW |