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

Side by Side Diff: tracing/tracing/metrics/webrtc/webrtc_rendering_metric.html

Issue 2771723003: [tracing] Move math utilities from base into their own subdirectory (attempt 2) (Closed)
Patch Set: rebase Created 3 years, 9 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright 2017 The Chromium Authors. All rights reserved. 3 Copyright 2017 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/unit.html"> 9 <link rel="import" href="/tracing/base/unit.html">
10 <link rel="import" href="/tracing/base/utils.html"> 10 <link rel="import" href="/tracing/base/utils.html">
11 <link rel="import" href="/tracing/metrics/metric_registry.html"> 11 <link rel="import" href="/tracing/metrics/metric_registry.html">
12 <link rel="import" href="/tracing/metrics/v8/utils.html"> 12 <link rel="import" href="/tracing/metrics/v8/utils.html">
13 <link rel="import" href="/tracing/value/histogram.html"> 13 <link rel="import" href="/tracing/value/histogram.html">
14 14
15 <script> 15 <script>
16 'use strict'; 16 'use strict';
17 17
18 tr.exportTo('tr.metrics.webrtc', function() { 18 tr.exportTo('tr.metrics.webrtc', function() {
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 let actualRenderBegin = event.args[ACTUAL_RENDER_BEGIN_NAME]; 259 let actualRenderBegin = event.args[ACTUAL_RENDER_BEGIN_NAME];
260 // When was the frame rendered vs. when it would've been ideal. 260 // When was the frame rendered vs. when it would've been ideal.
261 driftTime.push(actualRenderBegin - currentIdealRender); 261 driftTime.push(actualRenderBegin - currentIdealRender);
262 // The discrepancy is the absolute difference between the current Ideal 262 // The discrepancy is the absolute difference between the current Ideal
263 // Render and the expected Ideal Render. 263 // Render and the expected Ideal Render.
264 discrepancy.push(Math.abs(currentIdealRender - expectedIdealRender)); 264 discrepancy.push(Math.abs(currentIdealRender - expectedIdealRender));
265 expectedIdealRender = currentIdealRender; 265 expectedIdealRender = currentIdealRender;
266 oldIdealRender = currentIdealRender; 266 oldIdealRender = currentIdealRender;
267 } 267 }
268 268
269 let discrepancySum = tr.b.Statistics.sum(discrepancy) - discrepancy[0]; 269 let discrepancySum = tr.b.math.Statistics.sum(discrepancy) - discrepancy[0];
270 let lastIdealRender = 270 let lastIdealRender =
271 events[events.length - 1].args[IDEAL_RENDER_INSTANT_NAME]; 271 events[events.length - 1].args[IDEAL_RENDER_INSTANT_NAME];
272 let firstIdealRender = events[0].args[IDEAL_RENDER_INSTANT_NAME]; 272 let firstIdealRender = events[0].args[IDEAL_RENDER_INSTANT_NAME];
273 let idealRenderSpan = lastIdealRender - firstIdealRender; 273 let idealRenderSpan = lastIdealRender - firstIdealRender;
274 274
275 let renderingLengthError = discrepancySum / idealRenderSpan; 275 let renderingLengthError = discrepancySum / idealRenderSpan;
276 276
277 return {driftTime, renderingLengthError}; 277 return {driftTime, renderingLengthError};
278 } 278 }
279 279
280 /** 280 /**
281 * Get the smoothness stats from the normalized drift time. 281 * Get the smoothness stats from the normalized drift time.
282 * 282 *
283 * This method will calculate the smoothness score, along with the percentage 283 * This method will calculate the smoothness score, along with the percentage
284 * of frames badly out of sync and the percentage of frames out of sync. 284 * of frames badly out of sync and the percentage of frames out of sync.
285 * To be considered badly out of sync, a frame has to have missed rendering by 285 * To be considered badly out of sync, a frame has to have missed rendering by
286 * at least 2 * VSYNC_DURATION_US. 286 * at least 2 * VSYNC_DURATION_US.
287 * To be considered out of sync, a frame has to have missed rendering by at 287 * To be considered out of sync, a frame has to have missed rendering by at
288 * least one VSYNC_DURATION_US. 288 * least one VSYNC_DURATION_US.
289 * The smoothness score is a measure of how out of sync the frames are. 289 * The smoothness score is a measure of how out of sync the frames are.
290 * 290 *
291 * @param {Array.<Number>} driftTimes - See getDriftStats. 291 * @param {Array.<Number>} driftTimes - See getDriftStats.
292 * @returns {Object.<Number, Number, Number>} - The percentBadlyOutOfSync, 292 * @returns {Object.<Number, Number, Number>} - The percentBadlyOutOfSync,
293 * percentOutOfSync and smoothnesScore calculated from the driftTimes array. 293 * percentOutOfSync and smoothnesScore calculated from the driftTimes array.
294 */ 294 */
295 function getSmoothnessStats(driftTimes) { 295 function getSmoothnessStats(driftTimes) {
296 let meanDriftTime = tr.b.Statistics.mean(driftTimes); 296 let meanDriftTime = tr.b.math.Statistics.mean(driftTimes);
297 let normDriftTimes = driftTimes.map(driftTime => 297 let normDriftTimes = driftTimes.map(driftTime =>
298 Math.abs(driftTime - meanDriftTime)); 298 Math.abs(driftTime - meanDriftTime));
299 299
300 // How many times is a frame later/earlier than T=2*VSYNC_DURATION_US. Time 300 // How many times is a frame later/earlier than T=2*VSYNC_DURATION_US. Time
301 // is in microseconds 301 // is in microseconds
302 let framesSeverelyOutOfSync = normDriftTimes 302 let framesSeverelyOutOfSync = normDriftTimes
303 .filter(driftTime => driftTime > 2 * VSYNC_DURATION_US) 303 .filter(driftTime => driftTime > 2 * VSYNC_DURATION_US)
304 .length; 304 .length;
305 // How many times is a frame later/earlier than VSYNC_DURATION_US. 305 // How many times is a frame later/earlier than VSYNC_DURATION_US.
306 let framesOutOfSync = normDriftTimes 306 let framesOutOfSync = normDriftTimes
(...skipping 23 matching lines...) Expand all
330 percentOutOfSync, 330 percentOutOfSync,
331 smoothnessScore 331 smoothnessScore
332 }; 332 };
333 } 333 }
334 334
335 return { 335 return {
336 webrtcRenderingMetric, 336 webrtcRenderingMetric,
337 }; 337 };
338 }); 338 });
339 </script> 339 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/metrics/v8/utils.html ('k') | tracing/tracing/metrics/webrtc/webrtc_rendering_metric_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698