Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: Source/devtools/front_end/timeline/TimelineModel.js

Issue 1312563002: DevTools: [timeline tree view] fix total time calculation for recursive case. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: nodesStack -> nodesOnStack Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/inspector/tracing/timeline-js-callstacks-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 * @return {!WebInspector.TimelineModel.ProfileTreeNode} 1545 * @return {!WebInspector.TimelineModel.ProfileTreeNode}
1546 */ 1546 */
1547 WebInspector.TimelineModel.buildBottomUpTree = function(topDownTree, groupingCal lback) 1547 WebInspector.TimelineModel.buildBottomUpTree = function(topDownTree, groupingCal lback)
1548 { 1548 {
1549 var buRoot = new WebInspector.TimelineModel.ProfileTreeNode(); 1549 var buRoot = new WebInspector.TimelineModel.ProfileTreeNode();
1550 buRoot.selfTime = 0; 1550 buRoot.selfTime = 0;
1551 buRoot.totalTime = 0; 1551 buRoot.totalTime = 0;
1552 buRoot.name = WebInspector.UIString("Bottom-Up Chart"); 1552 buRoot.name = WebInspector.UIString("Bottom-Up Chart");
1553 /** @type {!Map<string,!WebInspector.TimelineModel.ProfileTreeNode>} */ 1553 /** @type {!Map<string,!WebInspector.TimelineModel.ProfileTreeNode>} */
1554 buRoot.children = new Map(); 1554 buRoot.children = new Map();
1555 processNode(topDownTree); 1555 var nodesOnStack = /** @type {!Set<string>} */ (new Set());
1556 topDownTree.children.forEach(processNode);
1556 1557
1557 /** 1558 /**
1558 * @param {!WebInspector.TimelineModel.ProfileTreeNode} tdNode 1559 * @param {!WebInspector.TimelineModel.ProfileTreeNode} tdNode
1559 */ 1560 */
1560 function processNode(tdNode) 1561 function processNode(tdNode)
1561 { 1562 {
1562 if (tdNode.selfTime > 0) { 1563 var buParent = groupingCallback && groupingCallback(tdNode) || buRoot;
1563 var buParent = groupingCallback && groupingCallback(tdNode) || buRoo t; 1564 appendNode(tdNode, buParent);
1564 appendNode(tdNode, buParent); 1565 var hadNode = nodesOnStack.has(tdNode.id);
1565 } 1566 if (!hadNode)
1567 nodesOnStack.add(tdNode.id);
1566 if (tdNode.children) 1568 if (tdNode.children)
1567 tdNode.children.forEach(processNode); 1569 tdNode.children.forEach(processNode);
1570 if (!hadNode)
1571 nodesOnStack.delete(tdNode.id);
1568 } 1572 }
1569 1573
1570 /** 1574 /**
1571 * @param {!WebInspector.TimelineModel.ProfileTreeNode} tdNode 1575 * @param {!WebInspector.TimelineModel.ProfileTreeNode} tdNode
1572 * @param {!WebInspector.TimelineModel.ProfileTreeNode} buParent 1576 * @param {!WebInspector.TimelineModel.ProfileTreeNode} buParent
1573 */ 1577 */
1574 function appendNode(tdNode, buParent) 1578 function appendNode(tdNode, buParent)
1575 { 1579 {
1576 var selfTime = tdNode.selfTime; 1580 var selfTime = tdNode.selfTime;
1577 var totalTime = tdNode.totalTime; 1581 var totalTime = tdNode.totalTime;
1578 buParent.selfTime += selfTime; 1582 buParent.selfTime += selfTime;
1579 buParent.totalTime += selfTime; 1583 buParent.totalTime += selfTime;
1580 while (tdNode.parent) { 1584 while (tdNode.parent) {
1581 if (!buParent.children) 1585 if (!buParent.children)
1582 buParent.children = /** @type {!Map<string,!WebInspector.Timelin eModel.ProfileTreeNode>} */ (new Map()); 1586 buParent.children = /** @type {!Map<string,!WebInspector.Timelin eModel.ProfileTreeNode>} */ (new Map());
1583 var id = tdNode.id; 1587 var id = tdNode.id;
1584 var buNode = buParent.children.get(id); 1588 var buNode = buParent.children.get(id);
1585 if (!buNode) { 1589 if (!buNode) {
1586 buNode = new WebInspector.TimelineModel.ProfileTreeNode(); 1590 buNode = new WebInspector.TimelineModel.ProfileTreeNode();
1587 buNode.selfTime = selfTime; 1591 buNode.selfTime = selfTime;
1588 buNode.totalTime = totalTime; 1592 buNode.totalTime = totalTime;
1589 buNode.name = tdNode.name; 1593 buNode.name = tdNode.name;
1590 buNode.event = tdNode.event; 1594 buNode.event = tdNode.event;
1591 buNode.id = id; 1595 buNode.id = id;
1592 buParent.children.set(id, buNode); 1596 buParent.children.set(id, buNode);
1593 } else { 1597 } else {
1594 buNode.selfTime += selfTime; 1598 buNode.selfTime += selfTime;
1595 buNode.totalTime += totalTime; 1599 if (!nodesOnStack.has(id))
1600 buNode.totalTime += totalTime;
1596 } 1601 }
1597 tdNode = tdNode.parent; 1602 tdNode = tdNode.parent;
1598 buParent = buNode; 1603 buParent = buNode;
1599 } 1604 }
1600 } 1605 }
1601 1606
1607 // Purge zero self time nodes.
1608 var rootChildren = buRoot.children;
1609 for (var item of rootChildren.entries()) {
1610 if (item[1].selfTime === 0)
1611 rootChildren.delete(item[0]);
1612 }
1613
1602 return buRoot; 1614 return buRoot;
1603 } 1615 }
1604 1616
1605 /** 1617 /**
1606 * @constructor 1618 * @constructor
1607 * @param {!WebInspector.TracingModel.Event} event 1619 * @param {!WebInspector.TracingModel.Event} event
1608 */ 1620 */
1609 WebInspector.TimelineModel.NetworkRequest = function(event) 1621 WebInspector.TimelineModel.NetworkRequest = function(event)
1610 { 1622 {
1611 this.startTime = event.name === WebInspector.TimelineModel.RecordType.Resour ceSendRequest ? event.startTime : 0; 1623 this.startTime = event.name === WebInspector.TimelineModel.RecordType.Resour ceSendRequest ? event.startTime : 0;
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
2350 /** @type {!Object.<string, !Array.<!WebInspector.InvalidationTrackingEv ent>>} */ 2362 /** @type {!Object.<string, !Array.<!WebInspector.InvalidationTrackingEv ent>>} */
2351 this._invalidations = {}; 2363 this._invalidations = {};
2352 /** @type {!Object.<number, !Array.<!WebInspector.InvalidationTrackingEv ent>>} */ 2364 /** @type {!Object.<number, !Array.<!WebInspector.InvalidationTrackingEv ent>>} */
2353 this._invalidationsByNodeId = {}; 2365 this._invalidationsByNodeId = {};
2354 2366
2355 this._lastRecalcStyle = undefined; 2367 this._lastRecalcStyle = undefined;
2356 this._lastPaintWithLayer = undefined; 2368 this._lastPaintWithLayer = undefined;
2357 this._didPaint = false; 2369 this._didPaint = false;
2358 } 2370 }
2359 } 2371 }
OLDNEW
« no previous file with comments | « LayoutTests/inspector/tracing/timeline-js-callstacks-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698