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

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

Issue 1292943002: DevTools: Add total time column to the timeline tree view (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: addressing comment 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 | « Source/devtools/front_end/timeline/TimelineModel.js ('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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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.VBox} 7 * @extends {WebInspector.VBox}
8 * @param {!WebInspector.TimelineModel} model 8 * @param {!WebInspector.TimelineModel} model
9 */ 9 */
10 WebInspector.TimelineTreeView = function(model) 10 WebInspector.TimelineTreeView = function(model)
11 { 11 {
12 WebInspector.VBox.call(this); 12 WebInspector.VBox.call(this);
13 this.element.classList.add("timeline-tree-view"); 13 this.element.classList.add("timeline-tree-view");
14 14
15 this._model = model; 15 this._model = model;
16 var columns = []; 16 var columns = [];
17 columns.push({id: "self", title: WebInspector.UIString("Self Time"), width: "120px", sort: WebInspector.DataGrid.Order.Descending, sortable: true}); 17 columns.push({id: "self", title: WebInspector.UIString("Self Time"), width: "120px", sort: WebInspector.DataGrid.Order.Descending, sortable: true});
18 columns.push({id: "total", title: WebInspector.UIString("Total Time"), width : "120px", sort: WebInspector.DataGrid.Order.Descending, sortable: true});
18 columns.push({id: "activity", title: WebInspector.UIString("Activity"), disc losure: true, sortable: true}); 19 columns.push({id: "activity", title: WebInspector.UIString("Activity"), disc losure: true, sortable: true});
19 20
20 this._filters = [ 21 this._filters = [
21 WebInspector.TimelineUIUtils.hiddenEventsFilter(), 22 WebInspector.TimelineUIUtils.hiddenEventsFilter(),
22 new WebInspector.ExcludeTopLevelFilter() 23 new WebInspector.ExcludeTopLevelFilter()
23 ]; 24 ];
24 25
25 this._groupBySetting = WebInspector.settings.createSetting("timelineTreeGrou pBy", WebInspector.TimelineTreeView.GroupBy.None); 26 this._groupBySetting = WebInspector.settings.createSetting("timelineTreeGrou pBy", WebInspector.TimelineTreeView.GroupBy.None);
26 27
27 this.dataGrid = new WebInspector.SortableDataGrid(columns); 28 this.dataGrid = new WebInspector.SortableDataGrid(columns);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 /** 91 /**
91 * @param {string} id 92 * @param {string} id
92 * @return {!WebInspector.TimelineModel.ProfileTreeNode} 93 * @return {!WebInspector.TimelineModel.ProfileTreeNode}
93 */ 94 */
94 function groupNodeById(id) 95 function groupNodeById(id)
95 { 96 {
96 var node = groupNodes.get(id); 97 var node = groupNodes.get(id);
97 if (!node) { 98 if (!node) {
98 node = new WebInspector.TimelineModel.ProfileTreeNode(); 99 node = new WebInspector.TimelineModel.ProfileTreeNode();
99 node.name = id || WebInspector.UIString("(unknown)"); 100 node.name = id || WebInspector.UIString("(unknown)");
101 node.selfTime = 0;
100 node.totalTime = 0; 102 node.totalTime = 0;
101 groupNodes.set(id, node); 103 groupNodes.set(id, node);
102 } 104 }
103 return node; 105 return node;
104 } 106 }
105 107
106 /** 108 /**
107 * @return {?WebInspector.TimelineModel.ProfileTreeNode} 109 * @return {?WebInspector.TimelineModel.ProfileTreeNode}
108 */ 110 */
109 function groupByNone() 111 function groupByNone()
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 */ 196 */
195 function compareField(field, a, b) 197 function compareField(field, a, b)
196 { 198 {
197 var nodeA = /** @type {!WebInspector.TimelineTreeView.GridNode} */ ( a); 199 var nodeA = /** @type {!WebInspector.TimelineTreeView.GridNode} */ ( a);
198 var nodeB = /** @type {!WebInspector.TimelineTreeView.GridNode} */ ( b); 200 var nodeB = /** @type {!WebInspector.TimelineTreeView.GridNode} */ ( b);
199 var valueA = nodeA._profileNode[field]; 201 var valueA = nodeA._profileNode[field];
200 var valueB = nodeB._profileNode[field]; 202 var valueB = nodeB._profileNode[field];
201 return valueA === valueB ? 0 : valueA > valueB ? 1 : -1; 203 return valueA === valueB ? 0 : valueA > valueB ? 1 : -1;
202 } 204 }
203 var field = { 205 var field = {
204 "self": "totalTime", 206 "self": "selfTime",
207 "total": "totalTime",
205 "activity": "name" 208 "activity": "name"
206 }[columnIdentifier]; 209 }[columnIdentifier];
207 this.dataGrid.sortNodes(compareField.bind(null, field), !this.dataGrid.i sSortOrderAscending()); 210 this.dataGrid.sortNodes(compareField.bind(null, field), !this.dataGrid.i sSortOrderAscending());
208 }, 211 },
209 212
210 __proto__: WebInspector.VBox.prototype 213 __proto__: WebInspector.VBox.prototype
211 } 214 }
212 215
213 /** 216 /**
214 * @param {!WebInspector.TracingModel.Event} event 217 * @param {!WebInspector.TracingModel.Event} event
(...skipping 30 matching lines...) Expand all
245 * @return {string} 248 * @return {string}
246 */ 249 */
247 function formatPercent(value) 250 function formatPercent(value)
248 { 251 {
249 return WebInspector.UIString("%.2f\u2009%%", value); 252 return WebInspector.UIString("%.2f\u2009%%", value);
250 } 253 }
251 254
252 this._populated = false; 255 this._populated = false;
253 this._profileNode = profileNode; 256 this._profileNode = profileNode;
254 this._totalTime = grandTotalTime; 257 this._totalTime = grandTotalTime;
255 var selfTime = profileNode.totalTime; 258 var selfTime = profileNode.selfTime;
256 var selfPercent = selfTime / grandTotalTime * 100; 259 var selfPercent = selfTime / grandTotalTime * 100;
260 var totalTime = profileNode.totalTime;
261 var totalPercent = totalTime / grandTotalTime * 100;
257 var data = { 262 var data = {
258 "activity": profileNode.name, 263 "activity": profileNode.name,
259 "self-percent": formatPercent(selfPercent), 264 "self-percent": formatPercent(selfPercent),
260 "self": formatMilliseconds(selfTime), 265 "self": formatMilliseconds(selfTime),
266 "total-percent": formatPercent(totalPercent),
267 "total": formatMilliseconds(totalTime),
261 }; 268 };
262 var hasChildren = this._profileNode.children ? this._profileNode.children.si ze > 0 : false; 269 var hasChildren = this._profileNode.children ? this._profileNode.children.si ze > 0 : false;
263 WebInspector.SortableDataGridNode.call(this, data, hasChildren); 270 WebInspector.SortableDataGridNode.call(this, data, hasChildren);
264 } 271 }
265 272
266 WebInspector.TimelineTreeView.GridNode.prototype = { 273 WebInspector.TimelineTreeView.GridNode.prototype = {
267 /** 274 /**
268 * @override 275 * @override
269 * @param {string} columnIdentifier 276 * @param {string} columnIdentifier
270 * @return {!Element} 277 * @return {!Element}
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 if (!this._profileNode.children) 348 if (!this._profileNode.children)
342 return; 349 return;
343 for (var node of this._profileNode.children.values()) { 350 for (var node of this._profileNode.children.values()) {
344 var gridNode = new WebInspector.TimelineTreeView.GridNode(node, this ._totalTime); 351 var gridNode = new WebInspector.TimelineTreeView.GridNode(node, this ._totalTime);
345 this.insertChildOrdered(gridNode); 352 this.insertChildOrdered(gridNode);
346 } 353 }
347 }, 354 },
348 355
349 __proto__: WebInspector.SortableDataGridNode.prototype 356 __proto__: WebInspector.SortableDataGridNode.prototype
350 } 357 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/timeline/TimelineModel.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698