12019-01-24 Joseph Pecoraro <pecoraro@apple.com>
2
3 Web Inspector: CPU Usage Timeline
4 https://bugs.webkit.org/show_bug.cgi?id=193730
5 <rdar://problem/46797201>
6
7 Reviewed by Devin Rousso.
8
9 CPU Usage is gathered in the backend twice a second, the frequency of the
10 ResourceUsageThread in WebCore. The frontend displays cpu usage in a few
11 ways in the Timeline.
12
13 We use a column chart in the timeline overview to display the frequency and
14 relative distance of samples. This helps show if the samples were close
15 together or far apart, which indicates how meaningful they will be at a
16 particular scale.
17
18 We use a line chart in the timeline detail view which will be easier to see
19 the changes over a particular time range selection.
20
21 * Localizations/en.lproj/localizedStrings.js:
22 New strings.
23
24 * UserInterface/Main.html:
25 * UserInterface/Base/Main.js:
26 (WI.loaded):
27 * UserInterface/Test.html:
28 * UserInterface/Test/Test.js:
29 (WI.loaded):
30 * UserInterface/Protocol/CPUProfilerObserver.js:
31 (WI.CPUProfilerObserver.prototype.trackingStart):
32 (WI.CPUProfilerObserver.prototype.trackingUpdate):
33 (WI.CPUProfilerObserver.prototype.trackingComplete):
34 (WI.CPUProfilerObserver):
35 New files and default registration.
36
37 * UserInterface/Protocol/Target.js:
38 (WI.Target.prototype.get CPUProfilerAgent):
39 New Agent.
40
41 * UserInterface/Controllers/TimelineManager.js:
42 (WI.TimelineManager.availableTimelineTypes):
43 (WI.TimelineManager.prototype.cpuProfilerTrackingStarted):
44 (WI.TimelineManager.prototype.cpuProfilerTrackingUpdated):
45 (WI.TimelineManager.prototype.cpuProfilerTrackingCompleted):
46 (WI.TimelineManager.prototype._updateAutoCaptureInstruments):
47 (WI.TimelineManager.prototype.memoryTrackingStart): Renamed.
48 (WI.TimelineManager.prototype.memoryTrackingUpdate): Renamed.
49 (WI.TimelineManager.prototype.memoryTrackingComplete): Renamed.
50 * UserInterface/Models/CPUInstrument.js:
51 (WI.CPUInstrument):
52 (WI.CPUInstrument.supported):
53 (WI.CPUInstrument.prototype.get timelineRecordType):
54 (WI.CPUInstrument.prototype.startInstrumentation):
55 (WI.CPUInstrument.prototype.stopInstrumentation):
56 * UserInterface/Models/CPUTimelineRecord.js:
57 (WI.CPUTimelineRecord):
58 (WI.CPUTimelineRecord.prototype.get timestamp):
59 (WI.CPUTimelineRecord.prototype.get usage):
60 * UserInterface/Models/Instrument.js:
61 (WI.Instrument.createForTimelineType):
62 * UserInterface/Models/TimelineRecord.js:
63 * UserInterface/Models/TimelineRecording.js:
64 (WI.TimelineRecording.prototype.addRecord):
65 Expose a new CPU instrument and timeline.
66
67 * UserInterface/Views/ColumnChart.js: Added.
68 (WI.ColumnChart):
69 (WI.ColumnChart.prototype.get element):
70 (WI.ColumnChart.prototype.get bars):
71 (WI.ColumnChart.prototype.get size):
72 (WI.ColumnChart.prototype.set size):
73 (WI.ColumnChart.prototype.addBar):
74 (WI.ColumnChart.prototype.clear):
75 (WI.ColumnChart.prototype.needsLayout):
76 (WI.ColumnChart.prototype.updateLayout):
77 View that will draw vertical bars with independent widths.
78 This is meant to be used similiar to WI.LineChart.
79
80 * UserInterface/Images/CPUInstrument.svg: Added.
81 * UserInterface/Views/Variables.css:
82 (:root):
83 CPU timeline colors and icon.
84
85 * UserInterface/Views/CPUTimelineOverviewGraph.css:
86 (body .sidebar > .panel.navigation.timeline > .timelines-content li.item.cpu,):
87 (.timeline-overview-graph.cpu):
88 (.timeline-overview-graph.cpu > .legend):
89 (body[dir=ltr] .timeline-overview-graph.cpu > .legend):
90 (body[dir=rtl] .timeline-overview-graph.cpu > .legend):
91 (.timeline-overview-graph:nth-child(even) > .legend):
92 (body[dir=rtl] .timeline-overview-graph.cpu > .bar-chart):
93 (.timeline-overview-graph.cpu > .bar-chart > svg > g > rect):
94 * UserInterface/Views/CPUTimelineOverviewGraph.js: Added.
95 (WI.CPUTimelineOverviewGraph):
96 (WI.CPUTimelineOverviewGraph.prototype.get height):
97 (WI.CPUTimelineOverviewGraph.prototype.reset):
98 (WI.CPUTimelineOverviewGraph.prototype.layout.xScale):
99 (WI.CPUTimelineOverviewGraph.prototype.layout.yScale):
100 (WI.CPUTimelineOverviewGraph.prototype.layout.yScaleForRecord):
101 (WI.CPUTimelineOverviewGraph.prototype.layout):
102 (WI.CPUTimelineOverviewGraph.prototype._updateLegend):
103 (WI.CPUTimelineOverviewGraph.prototype._cpuTimelineRecordAdded):
104 * UserInterface/Views/CPUTimelineView.css:
105 (.timeline-view.cpu):
106 (.timeline-view.cpu > .content):
107 (.timeline-view.cpu > .content .subtitle):
108 (.timeline-view.cpu > .content > .details):
109 (.timeline-view.cpu > .content > .details > .timeline-ruler):
110 (body[dir=ltr] .timeline-view.cpu > .content > .details > .timeline-ruler):
111 (body[dir=rtl] .timeline-view.cpu > .content > .details > .timeline-ruler):
112 (.timeline-view.cpu > .content > .details > .subtitle):
113 (.cpu-usage-view .line-chart > svg > path):
114 (.timeline-view.cpu .legend > .row > .swatch.current):
115 * UserInterface/Views/CPUTimelineView.js: Added.
116 (WI.CPUTimelineView):
117 (WI.CPUTimelineView.prototype.shown):
118 (WI.CPUTimelineView.prototype.hidden):
119 (WI.CPUTimelineView.prototype.closed):
120 (WI.CPUTimelineView.prototype.reset):
121 (WI.CPUTimelineView.prototype.get scrollableElements):
122 (WI.CPUTimelineView.prototype.get showsFilterBar):
123 (WI.CPUTimelineView.prototype.layout.layoutView):
124 (WI.CPUTimelineView.prototype.layout.xScale):
125 (WI.CPUTimelineView.prototype.layout.yScale):
126 (WI.CPUTimelineView.prototype.layout):
127 (WI.CPUTimelineView.prototype._cpuTimelineRecordAdded):
128 * UserInterface/Views/CPUUsageView.css:
129 (.cpu-usage-view):
130 (.cpu-usage-view > .details):
131 (body[dir=ltr] .cpu-usage-view > .details):
132 (body[dir=rtl] .cpu-usage-view > .details):
133 (.cpu-usage-view > .graph):
134 (body[dir=rtl] .cpu-usage-view > .graph):
135 * UserInterface/Views/CPUUsageView.js:
136 (WI.CPUUsageView):
137 (WI.CPUUsageView.prototype.get element):
138 (WI.CPUUsageView.prototype.clear):
139 (WI.CPUUsageView.prototype.layoutWithDataPoints):
140 (WI.CPUUsageView.prototype._updateDetails):
141 * UserInterface/Views/ContentView.js:
142 (WI.ContentView.createFromRepresentedObject):
143 * UserInterface/Views/TimelineIcons.css:
144 (.cpu-icon .icon):
145 * UserInterface/Views/TimelineOverviewGraph.js:
146 (WI.TimelineOverviewGraph.createForTimeline):
147 * UserInterface/Views/TimelineTabContentView.js:
148 (WI.TimelineTabContentView.displayNameForTimelineType):
149 (WI.TimelineTabContentView.iconClassNameForTimelineType):
150 (WI.TimelineTabContentView.genericClassNameForTimelineType):
151 (WI.TimelineTabContentView.iconClassNameForRecord):
152 (WI.TimelineTabContentView.displayNameForRecord):
153 Timeline views for CPU usage.
154
155 * UserInterface/Views/MemoryCategoryView.js:
156 (WI.MemoryCategoryView):
157 * UserInterface/Views/MemoryTimelineView.js:
158 (WI.MemoryTimelineView.createChartContainer):
159 (WI.MemoryTimelineView):
160 (WI.MemoryTimelineView.prototype._clearMaxComparisonLegend):
161 Minor updates to style and comments.
162