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

Side by Side Diff: tracing/tracing/metrics/webrtc/webrtc_rendering_metric_test.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/core/test_utils.html"> 8 <link rel="import" href="/tracing/core/test_utils.html">
9 <link rel="import" href="/tracing/extras/importer/trace_event_importer.html"> 9 <link rel="import" href="/tracing/extras/importer/trace_event_importer.html">
10 <link rel="import" href="/tracing/metrics/webrtc/webrtc_rendering_metric.html"> 10 <link rel="import" href="/tracing/metrics/webrtc/webrtc_rendering_metric.html">
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 test('driftTime', function() { 164 test('driftTime', function() {
165 // These numbers don't mean anything. We just want to make sure we can 165 // These numbers don't mean anything. We just want to make sure we can
166 // recover them after running the metric. 166 // recover them after running the metric.
167 let fakeDriftTimes = [16700, 17640, 15000, 24470, 16700, 14399, 17675]; 167 let fakeDriftTimes = [16700, 17640, 15000, 24470, 16700, 14399, 17675];
168 let fakeEvents = eventsFromDriftTimes(fakeDriftTimes); 168 let fakeEvents = eventsFromDriftTimes(fakeDriftTimes);
169 let histograms = runWebrtcRenderingMetric(fakeEvents); 169 let histograms = runWebrtcRenderingMetric(fakeEvents);
170 170
171 // We don't have access to the values stored in the histogram, so we check 171 // We don't have access to the values stored in the histogram, so we check
172 // for equality in the summary statistics. 172 // for equality in the summary statistics.
173 let hist = histograms.getHistogramNamed('WebRTCRendering_drift_time'); 173 let hist = histograms.getHistogramNamed('WebRTCRendering_drift_time');
174 assert.strictEqual(hist.sum, tr.b.Statistics.sum(fakeDriftTimes)); 174 assert.strictEqual(hist.sum, tr.b.math.Statistics.sum(fakeDriftTimes));
175 assert.strictEqual(hist.numValues, fakeDriftTimes.length); 175 assert.strictEqual(hist.numValues, fakeDriftTimes.length);
176 assert.strictEqual(hist.running.min, tr.b.Statistics.min(fakeDriftTimes)); 176 assert.strictEqual(hist.running.min,
177 assert.strictEqual(hist.running.max, tr.b.Statistics.max(fakeDriftTimes)); 177 tr.b.math.Statistics.min(fakeDriftTimes));
178 assert.strictEqual(hist.running.max,
179 tr.b.math.Statistics.max(fakeDriftTimes));
178 assert.closeTo(hist.standardDeviation, 180 assert.closeTo(hist.standardDeviation,
179 tr.b.Statistics.stddev(fakeDriftTimes), 1e-2); 181 tr.b.math.Statistics.stddev(fakeDriftTimes), 1e-2);
180 }); 182 });
181 183
182 test('framesBadlyOutOfSyncPerfect', function() { 184 test('framesBadlyOutOfSyncPerfect', function() {
183 // None of these will exceed the threshold for badly out of sync events, 185 // None of these will exceed the threshold for badly out of sync events,
184 // which is about 33 333. 186 // which is about 33 333.
185 let normDriftTimes = [-16700, 17640, 15000, -17640, -15000, 16700]; 187 let normDriftTimes = [-16700, 17640, 15000, -17640, -15000, 16700];
186 assert.strictEqual(tr.b.Statistics.sum(normDriftTimes), 0); 188 assert.strictEqual(tr.b.math.Statistics.sum(normDriftTimes), 0);
187 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes); 189 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes);
188 let histograms = runWebrtcRenderingMetric(fakeEvents); 190 let histograms = runWebrtcRenderingMetric(fakeEvents);
189 191
190 let hist = 192 let hist =
191 histograms.getHistogramNamed('WebRTCRendering_frames_badly_out_of_sync'); 193 histograms.getHistogramNamed('WebRTCRendering_frames_badly_out_of_sync');
192 assert.strictEqual(hist.numValues, 1); 194 assert.strictEqual(hist.numValues, 1);
193 assert.strictEqual(hist.running.mean, 0); 195 assert.strictEqual(hist.running.mean, 0);
194 }); 196 });
195 197
196 test('framesBadylOutOfSync', function() { 198 test('framesBadylOutOfSync', function() {
197 // Only 34 000 will exceed the threshold for badly out of sync events, 199 // Only 34 000 will exceed the threshold for badly out of sync events,
198 // which is about 33 333. 200 // which is about 33 333.
199 let normDriftTimes = [-34000, 10000, 10000, 10000, 4000]; 201 let normDriftTimes = [-34000, 10000, 10000, 10000, 4000];
200 assert.strictEqual(tr.b.Statistics.sum(normDriftTimes), 0); 202 assert.strictEqual(tr.b.math.Statistics.sum(normDriftTimes), 0);
201 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes); 203 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes);
202 let histograms = runWebrtcRenderingMetric(fakeEvents); 204 let histograms = runWebrtcRenderingMetric(fakeEvents);
203 205
204 let hist = 206 let hist =
205 histograms.getHistogramNamed('WebRTCRendering_frames_badly_out_of_sync'); 207 histograms.getHistogramNamed('WebRTCRendering_frames_badly_out_of_sync');
206 assert.strictEqual(hist.numValues, 1); 208 assert.strictEqual(hist.numValues, 1);
207 assert.strictEqual(hist.running.mean, 1); 209 assert.strictEqual(hist.running.mean, 1);
208 }); 210 });
209 211
210 test('framesOutOfSyncPerfect', function() { 212 test('framesOutOfSyncPerfect', function() {
211 // None of these will exceed the threshold for badly out of sync, which is 213 // None of these will exceed the threshold for badly out of sync, which is
212 // about 16 667. 214 // about 16 667.
213 let normDriftTimes = [-16600, 15640, 15000, -15640, -15000, 16600]; 215 let normDriftTimes = [-16600, 15640, 15000, -15640, -15000, 16600];
214 assert.strictEqual(tr.b.Statistics.sum(normDriftTimes), 0); 216 assert.strictEqual(tr.b.math.Statistics.sum(normDriftTimes), 0);
215 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes); 217 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes);
216 let histograms = runWebrtcRenderingMetric(fakeEvents); 218 let histograms = runWebrtcRenderingMetric(fakeEvents);
217 219
218 let hist = 220 let hist =
219 histograms.getHistogramNamed('WebRTCRendering_frames_out_of_sync'); 221 histograms.getHistogramNamed('WebRTCRendering_frames_out_of_sync');
220 assert.strictEqual(hist.numValues, 1); 222 assert.strictEqual(hist.numValues, 1);
221 assert.strictEqual(hist.running.mean, 0); 223 assert.strictEqual(hist.running.mean, 0);
222 }); 224 });
223 225
224 test('framesOutOfSync', function() { 226 test('framesOutOfSync', function() {
225 // Only 17000 will exceed the threshold for badly out of sync, which is 227 // Only 17000 will exceed the threshold for badly out of sync, which is
226 // about 16 667. 228 // about 16 667.
227 let normDriftTimes = [-17000, 5000, 5000, 5000, 2000]; 229 let normDriftTimes = [-17000, 5000, 5000, 5000, 2000];
228 assert.strictEqual(tr.b.Statistics.sum(normDriftTimes), 0); 230 assert.strictEqual(tr.b.math.Statistics.sum(normDriftTimes), 0);
229 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes); 231 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes);
230 let histograms = runWebrtcRenderingMetric(fakeEvents); 232 let histograms = runWebrtcRenderingMetric(fakeEvents);
231 233
232 let hist = 234 let hist =
233 histograms.getHistogramNamed('WebRTCRendering_frames_out_of_sync'); 235 histograms.getHistogramNamed('WebRTCRendering_frames_out_of_sync');
234 assert.strictEqual(hist.numValues, 1); 236 assert.strictEqual(hist.numValues, 1);
235 assert.strictEqual(hist.running.mean, 1); 237 assert.strictEqual(hist.running.mean, 1);
236 }); 238 });
237 239
238 test('percentBadlyOutOfSyncPerfect', function() { 240 test('percentBadlyOutOfSyncPerfect', function() {
239 // None of these will exceed the threshold for badly out of sync events, 241 // None of these will exceed the threshold for badly out of sync events,
240 // which is about 33 333. 242 // which is about 33 333.
241 let normDriftTimes = [-16700, 17640, 15000, -17640, -15000, 16700]; 243 let normDriftTimes = [-16700, 17640, 15000, -17640, -15000, 16700];
242 assert.strictEqual(tr.b.Statistics.sum(normDriftTimes), 0); 244 assert.strictEqual(tr.b.math.Statistics.sum(normDriftTimes), 0);
243 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes); 245 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes);
244 let histograms = runWebrtcRenderingMetric(fakeEvents); 246 let histograms = runWebrtcRenderingMetric(fakeEvents);
245 247
246 let hist = 248 let hist =
247 histograms.getHistogramNamed('WebRTCRendering_percent_badly_out_of_sync'); 249 histograms.getHistogramNamed('WebRTCRendering_percent_badly_out_of_sync');
248 assert.strictEqual(hist.numValues, 1); 250 assert.strictEqual(hist.numValues, 1);
249 assert.strictEqual(hist.running.mean, 0); 251 assert.strictEqual(hist.running.mean, 0);
250 }); 252 });
251 253
252 test('percentBadylOutOfSync', function() { 254 test('percentBadylOutOfSync', function() {
253 // Only 34 000 will exceed the threshold for badly out of sync events, 255 // Only 34 000 will exceed the threshold for badly out of sync events,
254 // which is about 33 333. 256 // which is about 33 333.
255 let normDriftTimes = [-34000, 10000, 10000, 10000, 4000]; 257 let normDriftTimes = [-34000, 10000, 10000, 10000, 4000];
256 assert.strictEqual(tr.b.Statistics.sum(normDriftTimes), 0); 258 assert.strictEqual(tr.b.math.Statistics.sum(normDriftTimes), 0);
257 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes); 259 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes);
258 let histograms = runWebrtcRenderingMetric(fakeEvents); 260 let histograms = runWebrtcRenderingMetric(fakeEvents);
259 261
260 let hist = 262 let hist =
261 histograms.getHistogramNamed('WebRTCRendering_percent_badly_out_of_sync'); 263 histograms.getHistogramNamed('WebRTCRendering_percent_badly_out_of_sync');
262 assert.strictEqual(hist.numValues, 1); 264 assert.strictEqual(hist.numValues, 1);
263 assert.strictEqual(hist.running.mean, .2); 265 assert.strictEqual(hist.running.mean, .2);
264 }); 266 });
265 267
266 test('percentOutOfSyncPerfect', function() { 268 test('percentOutOfSyncPerfect', function() {
267 // None of these will exceed the threshold for badly out of sync, which is 269 // None of these will exceed the threshold for badly out of sync, which is
268 // about 16 667. 270 // about 16 667.
269 let normDriftTimes = [-16600, 15640, 15000, -15640, -15000, 16600]; 271 let normDriftTimes = [-16600, 15640, 15000, -15640, -15000, 16600];
270 assert.strictEqual(tr.b.Statistics.sum(normDriftTimes), 0); 272 assert.strictEqual(tr.b.math.Statistics.sum(normDriftTimes), 0);
271 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes); 273 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes);
272 let histograms = runWebrtcRenderingMetric(fakeEvents); 274 let histograms = runWebrtcRenderingMetric(fakeEvents);
273 275
274 let hist = 276 let hist =
275 histograms.getHistogramNamed('WebRTCRendering_percent_out_of_sync'); 277 histograms.getHistogramNamed('WebRTCRendering_percent_out_of_sync');
276 assert.strictEqual(hist.numValues, 1); 278 assert.strictEqual(hist.numValues, 1);
277 assert.strictEqual(hist.running.mean, 0); 279 assert.strictEqual(hist.running.mean, 0);
278 }); 280 });
279 281
280 test('percentOutOfSync', function() { 282 test('percentOutOfSync', function() {
281 // Only 17000 will exceed the threshold for badly out of sync, which is 283 // Only 17000 will exceed the threshold for badly out of sync, which is
282 // about 16 667. 284 // about 16 667.
283 let normDriftTimes = [-17000, 5000, 5000, 5000, 2000]; 285 let normDriftTimes = [-17000, 5000, 5000, 5000, 2000];
284 assert.strictEqual(tr.b.Statistics.sum(normDriftTimes), 0); 286 assert.strictEqual(tr.b.math.Statistics.sum(normDriftTimes), 0);
285 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes); 287 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes);
286 let histograms = runWebrtcRenderingMetric(fakeEvents); 288 let histograms = runWebrtcRenderingMetric(fakeEvents);
287 289
288 let hist = 290 let hist =
289 histograms.getHistogramNamed('WebRTCRendering_percent_out_of_sync'); 291 histograms.getHistogramNamed('WebRTCRendering_percent_out_of_sync');
290 assert.strictEqual(hist.numValues, 1); 292 assert.strictEqual(hist.numValues, 1);
291 assert.strictEqual(hist.running.mean, .2); 293 assert.strictEqual(hist.running.mean, .2);
292 }); 294 });
293 295
294 test('smoothnessScorePerfect', function() { 296 test('smoothnessScorePerfect', function() {
295 // None of these will exceed the threshold for badly out of sync, which is 297 // None of these will exceed the threshold for badly out of sync, which is
296 // about 16 667, so the smoothnessScore wil be perfect. 298 // about 16 667, so the smoothnessScore wil be perfect.
297 let normDriftTimes = [-16600, 15640, 15000, -15640, -15000, 16600]; 299 let normDriftTimes = [-16600, 15640, 15000, -15640, -15000, 16600];
298 assert.strictEqual(tr.b.Statistics.sum(normDriftTimes), 0); 300 assert.strictEqual(tr.b.math.Statistics.sum(normDriftTimes), 0);
299 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes); 301 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes);
300 let histograms = runWebrtcRenderingMetric(fakeEvents); 302 let histograms = runWebrtcRenderingMetric(fakeEvents);
301 303
302 let hist = histograms.getHistogramNamed('WebRTCRendering_smoothness_score'); 304 let hist = histograms.getHistogramNamed('WebRTCRendering_smoothness_score');
303 assert.strictEqual(hist.numValues, 1); 305 assert.strictEqual(hist.numValues, 1);
304 assert.strictEqual(hist.running.mean, 1); 306 assert.strictEqual(hist.running.mean, 1);
305 }); 307 });
306 308
307 test('smoothnessScore', function() { 309 test('smoothnessScore', function() {
308 // One will exceed the threshold for frames badly out of sync (33 333) and 310 // One will exceed the threshold for frames badly out of sync (33 333) and
309 // another two the threshold for frames out of sync (16 667). So the 311 // another two the threshold for frames out of sync (16 667). So the
310 // smoothness score is 312 // smoothness score is
311 // 1 - (frames out of sync + 3 * frames badly out of sync) / n 313 // 1 - (frames out of sync + 3 * frames badly out of sync) / n
312 // = 1 - (2 + 3) / 5 = 0 314 // = 1 - (2 + 3) / 5 = 0
313 let normDriftTimes = [-17000, 34000, -17000, -10000, 10000]; 315 let normDriftTimes = [-17000, 34000, -17000, -10000, 10000];
314 assert.strictEqual(tr.b.Statistics.sum(normDriftTimes), 0); 316 assert.strictEqual(tr.b.math.Statistics.sum(normDriftTimes), 0);
315 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes); 317 let fakeEvents = eventsFromNormDriftTimes(normDriftTimes);
316 let histograms = runWebrtcRenderingMetric(fakeEvents); 318 let histograms = runWebrtcRenderingMetric(fakeEvents);
317 319
318 let hist = histograms.getHistogramNamed('WebRTCRendering_smoothness_score'); 320 let hist = histograms.getHistogramNamed('WebRTCRendering_smoothness_score');
319 assert.strictEqual(hist.numValues, 1); 321 assert.strictEqual(hist.numValues, 1);
320 assert.strictEqual(hist.running.mean, 0); 322 assert.strictEqual(hist.running.mean, 0);
321 }); 323 });
322 324
323 test('fpsPerfect', function() { 325 test('fpsPerfect', function() {
324 // Every frame is displayed once. This is a perfect FPS of 60. 326 // Every frame is displayed once. This is a perfect FPS of 60.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 let fakePairs = [[1, 0]]; 430 let fakePairs = [[1, 0]];
429 for (let i = 0; i < errors.length; ++i) { 431 for (let i = 0; i < errors.length; ++i) {
430 // Each frame's Ideal Render Instant is close to VSYNC_DURATION_US after 432 // Each frame's Ideal Render Instant is close to VSYNC_DURATION_US after
431 // the previous one, but with a known delay. 433 // the previous one, but with a known delay.
432 fakePairs.push([fakePairs[i][0] + VSYNC_DURATION_US + errors[i], 0]); 434 fakePairs.push([fakePairs[i][0] + VSYNC_DURATION_US + errors[i], 0]);
433 } 435 }
434 436
435 // The rendering length error is then the sum of the errors, normalized by 437 // The rendering length error is then the sum of the errors, normalized by
436 // the span between the first and the last Ideal Render Instants. 438 // the span between the first and the last Ideal Render Instants.
437 let idealRenderSpan = fakePairs[fakePairs.length - 1][0] - fakePairs[0][0]; 439 let idealRenderSpan = fakePairs[fakePairs.length - 1][0] - fakePairs[0][0];
438 let expectedRenderingLengthError = tr.b.Statistics.sum(errors) / 440 let expectedRenderingLengthError = tr.b.math.Statistics.sum(errors) /
439 idealRenderSpan; 441 idealRenderSpan;
440 442
441 let fakeEvents = fakePairs.map(eventFromPair); 443 let fakeEvents = fakePairs.map(eventFromPair);
442 let histograms = runWebrtcRenderingMetric(fakeEvents); 444 let histograms = runWebrtcRenderingMetric(fakeEvents);
443 445
444 let hist = 446 let hist =
445 histograms.getHistogramNamed('WebRTCRendering_rendering_length_error'); 447 histograms.getHistogramNamed('WebRTCRendering_rendering_length_error');
446 assert.strictEqual(hist.numValues, 1); 448 assert.strictEqual(hist.numValues, 1);
447 assert.closeTo(hist.running.mean, expectedRenderingLengthError, 1e-3); 449 assert.closeTo(hist.running.mean, expectedRenderingLengthError, 1e-3);
448 }); 450 });
449 }); 451 });
450 </script> 452 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/metrics/webrtc/webrtc_rendering_metric.html ('k') | tracing/tracing/model/async_slice_group.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698