Changeset 242740 in webkit
- Timestamp:
- Mar 11, 2019, 2:26:50 PM (6 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r242739 r242740 1 2019-03-11 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: CPU Usage Timeline - Better Thread chart layout values 4 https://bugs.webkit.org/show_bug.cgi?id=195547 5 6 Reviewed by Devin Rousso. 7 8 * UserInterface/Views/CPUTimelineView.js: 9 (WI.CPUTimelineView.prototype.layout.bestThreadLayoutMax): 10 (WI.CPUTimelineView.prototype.layout.layoutView): 11 (WI.CPUTimelineView.prototype._showGraphOverlay): 12 Include a separate layoutMax for the combined view and a thread layoutMax 13 for the thread groups. 14 1 15 2019-03-11 Joseph Pecoraro <pecoraro@apple.com> 2 16 -
trunk/Source/WebInspectorUI/UserInterface/Views/CPUTimelineView.js
r242739 r242740 461 461 let webkitThreadMax = -Infinity; 462 462 let unknownThreadMax = -Infinity; 463 let workerMax = -Infinity; 463 464 464 465 let min = Infinity; … … 578 579 unknownThreadAverage /= visibleRecords.length; 579 580 580 for (let [workerId, workerData] of workersDataMap) 581 for (let [workerId, workerData] of workersDataMap) { 581 582 workerData.average = workerData.average / workerData.recordsCount; 583 if (workerData.max > workerMax) 584 workerMax = workerData.max; 585 } 582 586 583 587 // If the graph end time is inside a gap, the last data point should … … 585 589 if (discontinuities.length) 586 590 visibleEndTime = discontinuities[0].startTime; 591 592 function bestThreadLayoutMax(value) { 593 if (value > 100) 594 return Math.ceil(value); 595 return (Math.floor(value / 25) + 1) * 25; 596 } 587 597 588 598 function removeGreaterThan(arr, max) { … … 622 632 } 623 633 624 // Layout all graphs to the same time scale. The maximum value is 625 // the maximum total CPU usage across all threads. 626 let layoutMax = max; 627 this._layoutMax = max; 628 629 function layoutView(view, property, graphHeight, {dataPoints, min, max, average}) { 634 function layoutView(view, property, graphHeight, layoutMax, {dataPoints, min, max, average}) { 630 635 if (min === Infinity) 631 636 min = 0; … … 686 691 } 687 692 688 layoutView(this._cpuUsageView, null, CPUTimelineView.cpuUsageViewHeight, {dataPoints, min, max, average}); 693 // Layout the combined graph to the maximum total CPU usage. 694 // Layout all the thread graphs to the same time scale, the maximum across threads / thread groups. 695 this._layoutMax = max; 696 this._threadLayoutMax = bestThreadLayoutMax(Math.max(mainThreadMax, webkitThreadMax, unknownThreadMax, workerMax)); 697 698 layoutView(this._cpuUsageView, null, CPUTimelineView.cpuUsageViewHeight, this._layoutMax, {dataPoints, min, max, average}); 689 699 690 700 if (this._threadsDetailsElement.open) { 691 layoutView(this._mainThreadUsageView, "mainThreadUsage", CPUTimelineView.threadCPUUsageViewHeight, {dataPoints, min: mainThreadMin, max: mainThreadMax, average: mainThreadAverage});692 layoutView(this._webkitThreadUsageView, "webkitThreadUsage", CPUTimelineView.threadCPUUsageViewHeight, {dataPoints, min: webkitThreadMin, max: webkitThreadMax, average: webkitThreadAverage});693 layoutView(this._unknownThreadUsageView, "unknownThreadUsage", CPUTimelineView.threadCPUUsageViewHeight, {dataPoints, min: unknownThreadMin, max: unknownThreadMax, average: unknownThreadAverage});701 layoutView(this._mainThreadUsageView, "mainThreadUsage", CPUTimelineView.threadCPUUsageViewHeight, this._threadLayoutMax, {dataPoints, min: mainThreadMin, max: mainThreadMax, average: mainThreadAverage}); 702 layoutView(this._webkitThreadUsageView, "webkitThreadUsage", CPUTimelineView.threadCPUUsageViewHeight, this._threadLayoutMax, {dataPoints, min: webkitThreadMin, max: webkitThreadMax, average: webkitThreadAverage}); 703 layoutView(this._unknownThreadUsageView, "unknownThreadUsage", CPUTimelineView.threadCPUUsageViewHeight, this._threadLayoutMax, {dataPoints, min: unknownThreadMin, max: unknownThreadMax, average: unknownThreadAverage}); 694 704 695 705 this._removeWorkerThreadViews(); … … 705 715 this._workerViews.push(workerView); 706 716 707 layoutView(workerView, "usage", CPUTimelineView.threadCPUUsageViewHeight, {dataPoints: workerData.dataPoints, min: workerData.min, max: workerData.max, average: workerData.average});717 layoutView(workerView, "usage", CPUTimelineView.threadCPUUsageViewHeight, this._threadLayoutMax, {dataPoints: workerData.dataPoints, min: workerData.min, max: workerData.max, average: workerData.average}); 708 718 } 709 719 } … … 1704 1714 this._overlayTime = time; 1705 1715 1706 let layoutMax = this._layoutMax;1707 1716 let secondsPerPixel = this._secondsPerPixelInLayout; 1708 let graphMax = layoutMax * 1.05;1709 1717 let graphStartTime = this.startTime; 1710 1718 … … 1719 1727 let {mainThreadUsage, workerThreadUsage, webkitThreadUsage, unknownThreadUsage, workersData} = record; 1720 1728 1721 function addOverlayPoint(view, graphHeight, value) {1729 function addOverlayPoint(view, graphHeight, layoutMax, value) { 1722 1730 if (!value) 1723 1731 return; 1724 1732 1733 let graphMax = layoutMax * 1.05; 1734 1725 1735 function yScale(value) { 1726 1736 return graphHeight - ((value / graphMax) * graphHeight); … … 1734 1744 1735 1745 this._cpuUsageView.updateLegend(record); 1736 addOverlayPoint(this._cpuUsageView, CPUTimelineView.cpuUsageViewHeight, mainThreadUsage);1737 addOverlayPoint(this._cpuUsageView, CPUTimelineView.cpuUsageViewHeight, mainThreadUsage + workerThreadUsage);1738 addOverlayPoint(this._cpuUsageView, CPUTimelineView.cpuUsageViewHeight, mainThreadUsage + workerThreadUsage + webkitThreadUsage + unknownThreadUsage);1746 addOverlayPoint(this._cpuUsageView, CPUTimelineView.cpuUsageViewHeight, this._layoutMax, mainThreadUsage); 1747 addOverlayPoint(this._cpuUsageView, CPUTimelineView.cpuUsageViewHeight, this._layoutMax, mainThreadUsage + workerThreadUsage); 1748 addOverlayPoint(this._cpuUsageView, CPUTimelineView.cpuUsageViewHeight, this._layoutMax, mainThreadUsage + workerThreadUsage + webkitThreadUsage + unknownThreadUsage); 1739 1749 1740 1750 if (this._threadsDetailsElement.open) { 1741 1751 this._mainThreadUsageView.updateLegend(mainThreadUsage); 1742 addOverlayPoint(this._mainThreadUsageView, CPUTimelineView.threadCPUUsageViewHeight, mainThreadUsage);1752 addOverlayPoint(this._mainThreadUsageView, CPUTimelineView.threadCPUUsageViewHeight, this._threadLayoutMax, mainThreadUsage); 1743 1753 1744 1754 this._webkitThreadUsageView.updateLegend(webkitThreadUsage); 1745 addOverlayPoint(this._webkitThreadUsageView, CPUTimelineView.threadCPUUsageViewHeight, webkitThreadUsage);1755 addOverlayPoint(this._webkitThreadUsageView, CPUTimelineView.threadCPUUsageViewHeight, this._threadLayoutMax, webkitThreadUsage); 1746 1756 1747 1757 this._unknownThreadUsageView.updateLegend(unknownThreadUsage); 1748 addOverlayPoint(this._unknownThreadUsageView, CPUTimelineView.threadCPUUsageViewHeight, unknownThreadUsage);1758 addOverlayPoint(this._unknownThreadUsageView, CPUTimelineView.threadCPUUsageViewHeight, this._threadLayoutMax, unknownThreadUsage); 1749 1759 1750 1760 for (let workerView of this._workerViews) … … 1756 1766 if (workerView) { 1757 1767 workerView.updateLegend(usage); 1758 addOverlayPoint(workerView, CPUTimelineView.threadCPUUsageViewHeight, usage);1768 addOverlayPoint(workerView, CPUTimelineView.threadCPUUsageViewHeight, this._threadLayoutMax, usage); 1759 1769 } 1760 1770 }
Note:
See TracChangeset
for help on using the changeset viewer.