| Index: third_party/WebKit/Source/devtools/front_end/sdk/ProfileTreeModel.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/ProfileTreeModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/ProfileTreeModel.js
|
| index 5ceb738dea1fd3d800b7b1685e409932dc1989c8..b8206f4e4d0e159a5fd14aacbc9ba1a4d0edfb64 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/sdk/ProfileTreeModel.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/sdk/ProfileTreeModel.js
|
| @@ -73,8 +73,8 @@ WebInspector.ProfileNode.prototype = {
|
| WebInspector.ProfileTreeModel = function(root)
|
| {
|
| this.root = root;
|
| - this.total = this._calculateTotals(this.root);
|
| this._assignDepthsAndParents();
|
| + this.total = this._calculateTotals(this.root);
|
| }
|
|
|
| WebInspector.ProfileTreeModel.prototype = {
|
| @@ -103,12 +103,23 @@ WebInspector.ProfileTreeModel.prototype = {
|
| },
|
|
|
| /**
|
| - * @param {!WebInspector.ProfileNode} node
|
| + * @param {!WebInspector.ProfileNode} root
|
| * @return {number}
|
| */
|
| - _calculateTotals: function(node)
|
| + _calculateTotals: function(root)
|
| {
|
| - node.total = node.children.reduce((acc, child) => acc + this._calculateTotals(child), node.self);
|
| - return node.total;
|
| + var nodesToTraverse = [root];
|
| + var dfsList = [];
|
| + while (nodesToTraverse.length) {
|
| + var node = nodesToTraverse.pop();
|
| + node.total = node.self;
|
| + dfsList.push(node);
|
| + nodesToTraverse.push(...node.children);
|
| + }
|
| + while (dfsList.length > 1) {
|
| + var node = dfsList.pop();
|
| + node.parent.total += node.total;
|
| + }
|
| + return root.total;
|
| }
|
| }
|
|
|