OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright 2016 The Chromium Authors. All rights reserved. | 3 Copyright 2016 The Chromium Authors. All rights reserved. |
4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
5 found in the LICENSE file. | 5 found in the LICENSE file. |
6 --> | 6 --> |
7 | 7 |
8 <link rel="import" href="/tracing/base/range.html"> | 8 <link rel="import" href="/tracing/base/math/range.html"> |
9 <link rel="import" href="/tracing/base/statistics.html"> | 9 <link rel="import" href="/tracing/base/math/statistics.html"> |
10 <link rel="import" href="/tracing/base/unit_scale.html"> | 10 <link rel="import" href="/tracing/base/unit_scale.html"> |
11 <link rel="import" href="/tracing/importer/find_input_expectations.html"> | 11 <link rel="import" href="/tracing/importer/find_input_expectations.html"> |
12 <link rel="import" href="/tracing/metrics/metric_registry.html"> | 12 <link rel="import" href="/tracing/metrics/metric_registry.html"> |
13 <link rel="import" href="/tracing/metrics/system_health/loading_metric.html"> | 13 <link rel="import" href="/tracing/metrics/system_health/loading_metric.html"> |
14 <link rel="import" href="/tracing/value/histogram.html"> | 14 <link rel="import" href="/tracing/value/histogram.html"> |
15 | 15 |
16 <script> | 16 <script> |
17 'use strict'; | 17 'use strict'; |
18 | 18 |
19 tr.exportTo('tr.metrics.sh', function() { | 19 tr.exportTo('tr.metrics.sh', function() { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 */ | 75 */ |
76 function getNavigationTTIIntervals_(model) { | 76 function getNavigationTTIIntervals_(model) { |
77 var chromeHelper = model.getOrCreateHelper( | 77 var chromeHelper = model.getOrCreateHelper( |
78 tr.model.helpers.ChromeModelHelper); | 78 tr.model.helpers.ChromeModelHelper); |
79 var intervals = []; | 79 var intervals = []; |
80 for (var rendererHelper of Object.values(chromeHelper.rendererHelpers)) { | 80 for (var rendererHelper of Object.values(chromeHelper.rendererHelpers)) { |
81 var samples = tr.metrics.sh.collectLoadingMetricsForRenderer( | 81 var samples = tr.metrics.sh.collectLoadingMetricsForRenderer( |
82 rendererHelper).firstInteractiveSamples; | 82 rendererHelper).firstInteractiveSamples; |
83 for (var sample of samples) { | 83 for (var sample of samples) { |
84 var info = sample.diagnostics['Navigation infos'].value; | 84 var info = sample.diagnostics['Navigation infos'].value; |
85 intervals.push(tr.b.Range.fromExplicitRange( | 85 intervals.push(tr.b.math.Range.fromExplicitRange( |
86 info.start, info.interactive)); | 86 info.start, info.interactive)); |
87 } | 87 } |
88 } | 88 } |
89 return intervals.sort((x, y) => x.min - y.min); | 89 return intervals.sort((x, y) => x.min - y.min); |
90 } | 90 } |
91 | 91 |
92 /** | 92 /** |
93 * Creates a histogram suitable for energy data. | 93 * Creates a histogram suitable for energy data. |
94 */ | 94 */ |
95 function createEnergyHistogram_(histograms, histogramName, description) { | 95 function createEnergyHistogram_(histograms, histogramName, description) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 return histogram; | 127 return histogram; |
128 } | 128 } |
129 | 129 |
130 /** | 130 /** |
131 * Generates the set of time intervals that metrics should be run over. | 131 * Generates the set of time intervals that metrics should be run over. |
132 * Time intervals include each UE (for UE-based metrics), the whole | 132 * Time intervals include each UE (for UE-based metrics), the whole |
133 * story (for the full-story metric), etc. Each time interval is given | 133 * story (for the full-story metric), etc. Each time interval is given |
134 * in the following form: | 134 * in the following form: |
135 * | 135 * |
136 * { | 136 * { |
137 * bounds {tr.b.Range}: Boundaries of the time interval. | 137 * bounds {tr.b.math.Range}: Boundaries of the time interval. |
138 * name {string}: Name of this interval. Used to generate the | 138 * name {string}: Name of this interval. Used to generate the |
139 * metric names. | 139 * metric names. |
140 * description {string}: Human readable description of the interval. | 140 * description {string}: Human readable description of the interval. |
141 * Used to generate the metric descriptions. | 141 * Used to generate the metric descriptions. |
142 * perSecond {boolean}: Whether metrics over this interval should be | 142 * perSecond {boolean}: Whether metrics over this interval should be |
143 * reported as per-second values (e.g. power). If not, integrated values | 143 * reported as per-second values (e.g. power). If not, integrated values |
144 * over the whole interval (e.g. energy) are reported. | 144 * over the whole interval (e.g. energy) are reported. |
145 * } | 145 * } |
146 * | 146 * |
147 */ | 147 */ |
(...skipping 10 matching lines...) Expand all Loading... |
158 yield { | 158 yield { |
159 bounds: model.bounds, | 159 bounds: model.bounds, |
160 name: 'story', | 160 name: 'story', |
161 description: 'user story', | 161 description: 'user story', |
162 perSecond: true | 162 perSecond: true |
163 }; | 163 }; |
164 | 164 |
165 var chromeBounds = computeChromeBounds_(model); | 165 var chromeBounds = computeChromeBounds_(model); |
166 if (chromeBounds.isEmpty) return; | 166 if (chromeBounds.isEmpty) return; |
167 | 167 |
168 var powerSeriesBoundsWithGracePeriod = tr.b.Range.fromExplicitRange( | 168 var powerSeriesBoundsWithGracePeriod = tr.b.math.Range.fromExplicitRange( |
169 powerSeries.bounds.min - CHROME_POWER_GRACE_PERIOD_MS, | 169 powerSeries.bounds.min - CHROME_POWER_GRACE_PERIOD_MS, |
170 powerSeries.bounds.max + CHROME_POWER_GRACE_PERIOD_MS); | 170 powerSeries.bounds.max + CHROME_POWER_GRACE_PERIOD_MS); |
171 if (!powerSeriesBoundsWithGracePeriod.containsRangeExclusive( | 171 if (!powerSeriesBoundsWithGracePeriod.containsRangeExclusive( |
172 chromeBounds)) { | 172 chromeBounds)) { |
173 return; | 173 return; |
174 } | 174 } |
175 | 175 |
176 // If Chrome bounds are good and the power trace covers the Chrome bounds, | 176 // If Chrome bounds are good and the power trace covers the Chrome bounds, |
177 // then output the Chrome specific metrics (loading and RAIL stages). Note | 177 // then output the Chrome specific metrics (loading and RAIL stages). Note |
178 // that only the part of the time interval that overlaps the Chrome bounds | 178 // that only the part of the time interval that overlaps the Chrome bounds |
(...skipping 18 matching lines...) Expand all Loading... |
197 } | 197 } |
198 | 198 |
199 /** | 199 /** |
200 * Gets a list of time intervals for the RAIL stages. Each RAIL stage | 200 * Gets a list of time intervals for the RAIL stages. Each RAIL stage |
201 * generates a time interval with the name equal to the name of the RAIL | 201 * generates a time interval with the name equal to the name of the RAIL |
202 * stage except made into lower case and with spaces replaced bu underscores | 202 * stage except made into lower case and with spaces replaced bu underscores |
203 * e.g. "Scroll Animation" --> "scroll_animation". Each time interval is given | 203 * e.g. "Scroll Animation" --> "scroll_animation". Each time interval is given |
204 * in the following form: | 204 * in the following form: |
205 * | 205 * |
206 * { | 206 * { |
207 * bounds {tr.b.Range}: Boundaries of the time interval. | 207 * bounds {tr.b.math.Range}: Boundaries of the time interval. |
208 * name {string}: Name of this interval. Used to generate the | 208 * name {string}: Name of this interval. Used to generate the |
209 * metric names. | 209 * metric names. |
210 * description {string}: Human readable description of the interval. | 210 * description {string}: Human readable description of the interval. |
211 * Used to generate the metric descriptions. | 211 * Used to generate the metric descriptions. |
212 * perSecond {boolean}: Whether metrics over this interval should be | 212 * perSecond {boolean}: Whether metrics over this interval should be |
213 * reported as per-second values (e.g. power). If not, integrated values | 213 * reported as per-second values (e.g. power). If not, integrated values |
214 * over the whole interval (e.g. energy) are reported. | 214 * over the whole interval (e.g. energy) are reported. |
215 * } | 215 * } |
216 * | 216 * |
217 */ | 217 */ |
218 function* getRailStageIntervals_(model) { | 218 function* getRailStageIntervals_(model) { |
219 for (var exp of model.userModel.expectations) { | 219 for (var exp of model.userModel.expectations) { |
220 var histogramName = exp.title.toLowerCase().replace(' ', '_'); | 220 var histogramName = exp.title.toLowerCase().replace(' ', '_'); |
221 var energyHist = undefined; | 221 var energyHist = undefined; |
222 if (histogramName.includes('response')) { | 222 if (histogramName.includes('response')) { |
223 yield { | 223 yield { |
224 bounds: tr.b.Range.fromExplicitRange(exp.start, exp.end), | 224 bounds: tr.b.math.Range.fromExplicitRange(exp.start, exp.end), |
225 name: histogramName, | 225 name: histogramName, |
226 description: 'RAIL stage ' + histogramName, | 226 description: 'RAIL stage ' + histogramName, |
227 perSecond: false | 227 perSecond: false |
228 }; | 228 }; |
229 } else if (histogramName.includes('animation') || | 229 } else if (histogramName.includes('animation') || |
230 histogramName.includes('idle')) { | 230 histogramName.includes('idle')) { |
231 yield { | 231 yield { |
232 bounds: tr.b.Range.fromExplicitRange(exp.start, exp.end), | 232 bounds: tr.b.math.Range.fromExplicitRange(exp.start, exp.end), |
233 name: histogramName, | 233 name: histogramName, |
234 description: 'RAIL stage ' + histogramName, | 234 description: 'RAIL stage ' + histogramName, |
235 perSecond: true | 235 perSecond: true |
236 }; | 236 }; |
237 } | 237 } |
238 } | 238 } |
239 } | 239 } |
240 | 240 |
241 /** | 241 /** |
242 * Gets a list of time intervals for the RAIL stages. Each RAIL stage | 242 * Gets a list of time intervals for the RAIL stages. Each RAIL stage |
243 * generates a time interval with the name equal to the name of the RAIL | 243 * generates a time interval with the name equal to the name of the RAIL |
244 * stage except made into lower case and with spaces replaced bu underscores | 244 * stage except made into lower case and with spaces replaced bu underscores |
245 * e.g. "Scroll Animation" --> "scroll_animation". Each time interval is given | 245 * e.g. "Scroll Animation" --> "scroll_animation". Each time interval is given |
246 * in the following form: | 246 * in the following form: |
247 * | 247 * |
248 * { | 248 * { |
249 * bounds {tr.b.Range}: Boundaries of the time interval. | 249 * bounds {tr.b.math.Range}: Boundaries of the time interval. |
250 * name {string}: Name of this interval. Used to generate the | 250 * name {string}: Name of this interval. Used to generate the |
251 * metric names. | 251 * metric names. |
252 * description {string}: Human readable description of the interval. | 252 * description {string}: Human readable description of the interval. |
253 * Used to generate the metric descriptions. | 253 * Used to generate the metric descriptions. |
254 * perSecond {boolean}: Whether metrics over this interval should be | 254 * perSecond {boolean}: Whether metrics over this interval should be |
255 * reported as per-second values (e.g. power). If not, integrated values | 255 * reported as per-second values (e.g. power). If not, integrated values |
256 * over the whole interval (e.g. energy) are reported. | 256 * over the whole interval (e.g. energy) are reported. |
257 * } | 257 * } |
258 * | 258 * |
259 */ | 259 */ |
260 function* getLoadingIntervals_(model, chromeBounds) { | 260 function* getLoadingIntervals_(model, chromeBounds) { |
261 var ttiIntervals = getNavigationTTIIntervals_(model); | 261 var ttiIntervals = getNavigationTTIIntervals_(model); |
262 var lastLoadTime = undefined; | 262 var lastLoadTime = undefined; |
263 for (var ttiInterval of ttiIntervals) { | 263 for (var ttiInterval of ttiIntervals) { |
264 yield { | 264 yield { |
265 bounds: ttiInterval, | 265 bounds: ttiInterval, |
266 name: 'load', | 266 name: 'load', |
267 description: 'page loads', | 267 description: 'page loads', |
268 perSecond: false | 268 perSecond: false |
269 }; | 269 }; |
270 lastLoadTime = lastLoadTime === undefined ? ttiInterval.max : | 270 lastLoadTime = lastLoadTime === undefined ? ttiInterval.max : |
271 Math.max(lastLoadTime, ttiInterval.max); | 271 Math.max(lastLoadTime, ttiInterval.max); |
272 } | 272 } |
273 if (lastLoadTime !== undefined) { | 273 if (lastLoadTime !== undefined) { |
274 yield { | 274 yield { |
275 bounds: tr.b.Range.fromExplicitRange( | 275 bounds: tr.b.math.Range.fromExplicitRange( |
276 lastLoadTime, chromeBounds.max), | 276 lastLoadTime, chromeBounds.max), |
277 name: 'after_load', | 277 name: 'after_load', |
278 description: 'period after load', | 278 description: 'period after load', |
279 perSecond: true | 279 perSecond: true |
280 }; | 280 }; |
281 } | 281 } |
282 } | 282 } |
283 | 283 |
284 /** | 284 /** |
285 * @returns {tr.b.Range} The boundaries of the Chrome portion of the trace. | 285 * @returns {tr.b.math.Range} The boundaries of the Chrome portion of the |
| 286 * trace. |
286 */ | 287 */ |
287 function computeChromeBounds_(model) { | 288 function computeChromeBounds_(model) { |
288 var chromeBounds = new tr.b.Range(); | 289 var chromeBounds = new tr.b.math.Range(); |
289 var chromeHelper = model.getOrCreateHelper( | 290 var chromeHelper = model.getOrCreateHelper( |
290 tr.model.helpers.ChromeModelHelper); | 291 tr.model.helpers.ChromeModelHelper); |
291 if (chromeHelper === undefined) return chromeBounds; | 292 if (chromeHelper === undefined) return chromeBounds; |
292 for (var helper of chromeHelper.browserHelpers) { | 293 for (var helper of chromeHelper.browserHelpers) { |
293 if (helper.mainThread) { | 294 if (helper.mainThread) { |
294 chromeBounds.addRange(helper.mainThread.bounds); | 295 chromeBounds.addRange(helper.mainThread.bounds); |
295 } | 296 } |
296 } | 297 } |
297 for (var pid in chromeHelper.rendererHelpers) { | 298 for (var pid in chromeHelper.rendererHelpers) { |
298 if (chromeHelper.rendererHelpers[pid].mainThread) { | 299 if (chromeHelper.rendererHelpers[pid].mainThread) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 createHistograms_(data, interval, histograms); | 368 createHistograms_(data, interval, histograms); |
368 } | 369 } |
369 | 370 |
370 tr.metrics.MetricRegistry.register(powerMetric); | 371 tr.metrics.MetricRegistry.register(powerMetric); |
371 | 372 |
372 return { | 373 return { |
373 powerMetric | 374 powerMetric |
374 }; | 375 }; |
375 }); | 376 }); |
376 </script> | 377 </script> |
OLD | NEW |