Chromium Code Reviews| OLD | NEW |
|---|---|
| 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) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 }, | 111 }, |
| 112 | 112 |
| 113 _refreshTree: function() | 113 _refreshTree: function() |
| 114 { | 114 { |
| 115 this.dataGrid.rootNode().removeChildren(); | 115 this.dataGrid.rootNode().removeChildren(); |
| 116 var topDown = WebInspector.TimelineModel.buildTopDownTree( | 116 var topDown = WebInspector.TimelineModel.buildTopDownTree( |
| 117 this._model.mainThreadEvents(), this._startTime, this._endTime, this ._filters, WebInspector.TimelineTreeView.eventId); | 117 this._model.mainThreadEvents(), this._startTime, this._endTime, this ._filters, WebInspector.TimelineTreeView.eventId); |
| 118 var tree = this._modeCombobox.selectedOption().value === WebInspector.Ti melineTreeView.Mode.TopDown | 118 var tree = this._modeCombobox.selectedOption().value === WebInspector.Ti melineTreeView.Mode.TopDown |
| 119 ? this._preformTopDownTreeGrouping(topDown) | 119 ? this._preformTopDownTreeGrouping(topDown) |
| 120 : this._buildBottomUpTree(topDown); | 120 : this._buildBottomUpTree(topDown); |
| 121 var maxSelfTime = 0; | |
| 122 var maxTotalTime = 0; | |
| 123 for (var child of tree.children.values()) { | |
| 124 maxSelfTime = Math.max(maxSelfTime, child.selfTime); | |
| 125 maxTotalTime = Math.max(maxTotalTime, child.totalTime); | |
| 126 } | |
| 121 for (var child of tree.children.values()) { | 127 for (var child of tree.children.values()) { |
| 122 // Exclude the idle time off the total calculation. | 128 // Exclude the idle time off the total calculation. |
| 123 var gridNode = new WebInspector.TimelineTreeView.GridNode(child, top Down.totalTime); | 129 var gridNode = new WebInspector.TimelineTreeView.GridNode(child, top Down.totalTime, maxSelfTime, maxTotalTime); |
| 124 this.dataGrid.insertChild(gridNode); | 130 this.dataGrid.insertChild(gridNode); |
| 125 } | 131 } |
| 126 this._sortingChanged(); | 132 this._sortingChanged(); |
| 127 }, | 133 }, |
| 128 | 134 |
| 129 /** | 135 /** |
| 130 * @param {!WebInspector.TimelineModel.ProfileTreeNode} topDownTree | 136 * @param {!WebInspector.TimelineModel.ProfileTreeNode} topDownTree |
| 131 * @return {!WebInspector.TimelineModel.ProfileTreeNode} | 137 * @return {!WebInspector.TimelineModel.ProfileTreeNode} |
| 132 */ | 138 */ |
| 133 _preformTopDownTreeGrouping: function(topDownTree) | 139 _preformTopDownTreeGrouping: function(topDownTree) |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 var url = data && data["url"]; | 287 var url = data && data["url"]; |
| 282 if (url) | 288 if (url) |
| 283 return url; | 289 return url; |
| 284 var topFrame = event.stackTrace && event.stackTrace[0]; | 290 var topFrame = event.stackTrace && event.stackTrace[0]; |
| 285 return topFrame && topFrame["url"] || null; | 291 return topFrame && topFrame["url"] || null; |
| 286 } | 292 } |
| 287 | 293 |
| 288 /** | 294 /** |
| 289 * @constructor | 295 * @constructor |
| 290 * @extends {WebInspector.SortableDataGridNode} | 296 * @extends {WebInspector.SortableDataGridNode} |
| 291 * @param {?} profileNode | 297 * @param {!WebInspector.TimelineModel.ProfileTreeNode} profileNode |
| 292 * @param {number} grandTotalTime | 298 * @param {number} grandTotalTime |
| 299 * @param {number} maxSelfTime | |
| 300 * @param {number} maxTotalTime | |
| 293 */ | 301 */ |
| 294 WebInspector.TimelineTreeView.GridNode = function(profileNode, grandTotalTime) | 302 WebInspector.TimelineTreeView.GridNode = function(profileNode, grandTotalTime, m axSelfTime, maxTotalTime) |
| 295 { | 303 { |
| 296 /** | 304 /** |
| 297 * @param {number} time | 305 * @param {number} time |
| 298 * @return {string} | 306 * @return {string} |
| 299 */ | 307 */ |
| 300 function formatMilliseconds(time) | 308 function formatMilliseconds(time) |
| 301 { | 309 { |
| 302 return WebInspector.UIString("%.1f\u2009ms", time); | 310 return WebInspector.UIString("%.1f\u2009ms", time); |
| 303 } | 311 } |
| 304 /** | 312 /** |
| 305 * @param {number} value | 313 * @param {number} value |
| 306 * @return {string} | 314 * @return {string} |
| 307 */ | 315 */ |
| 308 function formatPercent(value) | 316 function formatPercent(value) |
| 309 { | 317 { |
| 310 return WebInspector.UIString("%.2f\u2009%%", value); | 318 return WebInspector.UIString("%.2f\u2009%%", value); |
| 311 } | 319 } |
| 312 | 320 |
| 313 this._populated = false; | 321 this._populated = false; |
| 314 this._profileNode = profileNode; | 322 this._profileNode = profileNode; |
| 315 this._totalTime = grandTotalTime; | 323 this._totalTime = grandTotalTime; |
| 324 this._maxTime = { self: maxSelfTime, total: maxTotalTime }; | |
|
caseq
2015/08/18 21:06:29
maxTimes?
alph
2015/08/18 21:16:19
Done.
| |
| 316 var selfTime = profileNode.selfTime; | 325 var selfTime = profileNode.selfTime; |
| 317 var selfPercent = selfTime / grandTotalTime * 100; | 326 var selfPercent = selfTime / grandTotalTime * 100; |
| 318 var totalTime = profileNode.totalTime; | 327 var totalTime = profileNode.totalTime; |
| 319 var totalPercent = totalTime / grandTotalTime * 100; | 328 var totalPercent = totalTime / grandTotalTime * 100; |
| 320 var data = { | 329 var data = { |
| 321 "activity": profileNode.name, | 330 "activity": profileNode.name, |
| 322 "self-percent": formatPercent(selfPercent), | 331 "self-percent": formatPercent(selfPercent), |
| 323 "self": formatMilliseconds(selfTime), | 332 "self": formatMilliseconds(selfTime), |
| 324 "total-percent": formatPercent(totalPercent), | 333 "total-percent": formatPercent(totalPercent), |
| 325 "total": formatMilliseconds(totalTime), | 334 "total": formatMilliseconds(totalTime), |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 }, | 379 }, |
| 371 | 380 |
| 372 /** | 381 /** |
| 373 * @param {string} columnIdentifier | 382 * @param {string} columnIdentifier |
| 374 * @return {?Element} | 383 * @return {?Element} |
| 375 */ | 384 */ |
| 376 _createValueCell: function(columnIdentifier) | 385 _createValueCell: function(columnIdentifier) |
| 377 { | 386 { |
| 378 if (columnIdentifier !== "self" && columnIdentifier !== "total") | 387 if (columnIdentifier !== "self" && columnIdentifier !== "total") |
| 379 return null; | 388 return null; |
| 380 | |
| 381 var cell = this.createTD(columnIdentifier); | 389 var cell = this.createTD(columnIdentifier); |
| 382 cell.className = "numeric-column"; | 390 cell.className = "numeric-column"; |
| 383 var div = createElement("div"); | 391 var textDiv = cell.createChild("div"); |
| 384 var valueSpan = createElement("span"); | 392 textDiv.createChild("span").textContent = this.data[columnIdentifier]; |
| 385 valueSpan.textContent = this.data[columnIdentifier]; | |
| 386 div.appendChild(valueSpan); | |
| 387 var percentColumn = columnIdentifier + "-percent"; | 393 var percentColumn = columnIdentifier + "-percent"; |
| 388 if (percentColumn in this.data) { | 394 if (percentColumn in this.data) { |
| 389 var percentSpan = createElement("span"); | 395 textDiv.createChild("span", "percent-column").textContent = this.dat a[percentColumn]; |
| 390 percentSpan.className = "percent-column"; | 396 textDiv.classList.add("profile-multiple-values"); |
| 391 percentSpan.textContent = this.data[percentColumn]; | |
| 392 div.appendChild(percentSpan); | |
| 393 div.classList.add("profile-multiple-values"); | |
| 394 } | 397 } |
| 395 cell.appendChild(div); | 398 cell.createChild("div", "background-bar").style.width = this._profileNod e[columnIdentifier + "Time"] * 100 / this._maxTime[columnIdentifier] + "%"; |
|
caseq
2015/08/18 21:06:29
explicitly format as decimal to prevent accidental
alph
2015/08/18 21:16:19
Done.
| |
| 396 return cell; | 399 return cell; |
| 397 }, | 400 }, |
| 398 | 401 |
| 399 /** | 402 /** |
| 400 * @override | 403 * @override |
| 401 */ | 404 */ |
| 402 populate: function() | 405 populate: function() |
| 403 { | 406 { |
| 404 if (this._populated) | 407 if (this._populated) |
| 405 return; | 408 return; |
| 406 this._populated = true; | 409 this._populated = true; |
| 407 if (!this._profileNode.children) | 410 if (!this._profileNode.children) |
| 408 return; | 411 return; |
| 409 for (var node of this._profileNode.children.values()) { | 412 for (var node of this._profileNode.children.values()) { |
| 410 var gridNode = new WebInspector.TimelineTreeView.GridNode(node, this ._totalTime); | 413 var gridNode = new WebInspector.TimelineTreeView.GridNode(node, this ._totalTime, this._maxTime.self, this._maxTime.total); |
| 411 this.insertChildOrdered(gridNode); | 414 this.insertChildOrdered(gridNode); |
| 412 } | 415 } |
| 413 }, | 416 }, |
| 414 | 417 |
| 415 __proto__: WebInspector.SortableDataGridNode.prototype | 418 __proto__: WebInspector.SortableDataGridNode.prototype |
| 416 } | 419 } |
| OLD | NEW |