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

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

Issue 2711623002: Add a TBMv2 webrtc_rendering_metric. (Closed)
Patch Set: New test for driftTime 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
« no previous file with comments | « tracing/tracing/metrics/webrtc/webrtc_rendering_metric.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <!--
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
5 found in the LICENSE file.
6 -->
7
8 <link rel="import" href="/tracing/core/test_utils.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">
11 <link rel="import" href="/tracing/model/slice_group.html">
12 <link rel="import" href="/tracing/value/histogram.html">
13 <link rel="import" href="/tracing/value/histogram_set.html">
14
15 <script>
16 'use strict';
17
18 tr.b.unittest.testSuite(function() {
19 function eventFromPair(pair) {
20 return {
21 title: 'WebMediaPlayerMS::UpdateCurrentFrame',
22 start: pair[1],
23 duration: 1,
24 args: {
25 'Ideal Render Instant': pair[0],
26 'Actual Render Begin': pair[1],
27 'Actual Render End': 0,
28 'Serial': 0,
29 }
30 };
31 }
32
33 function newModel(fakeEvents) {
34 function customizeModelCallback(model) {
35 const rendererProcess = model.getOrCreateProcess(1);
36 const mainThread = rendererProcess.getOrCreateThread(2);
37 for (const event of fakeEvents) {
38 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx(event));
39 }
40 }
41 return tr.c.TestUtils.newModelWithEvents([], {customizeModelCallback});
42 }
43
44 function runWebrtcRenderingMetric(fakeEvents) {
45 let values = new tr.v.HistogramSet();
46 let model = newModel(fakeEvents);
47 tr.metrics.webrtc.webrtcRenderingMetric(values, model);
48 return values;
49 }
50
51 test('driftTime', function() {
52 // These numbers don't mean anything. We just want to make sure we can
ehmaldonado_chromium 2017/03/01 21:59:05 Tim, what do you think of this way to test driftTi
tdresser 2017/03/02 13:19:01 This LGTM, thanks.
53 // recover them after running the metric.
54 let fakeDriftTimes = [67, 764, 15, 3447, 67, 43, 767];
55
56 // Create fake events from the fake drift times. For the i-th drift time,
57 // we'll create an event with 'Ideal Render Instant' = i and
58 // 'Actual Render Instant' = i + fakeDriftTimes[i].
59 let fakeEvents = [];
60 for (const driftTime of fakeDriftTimes) {
61 let lastTime = 0;
62 if (fakeEvents.length > 0) {
63 lastTime = fakeEvents[fakeEvents.length - 1][0] + 1;
64 }
65 fakeEvents.push([lastTime, lastTime + driftTime]);
66 }
tdresser 2017/03/02 13:19:01 It's a bit confusing to keep track of what's ideal
ehmaldonado_chromium 2017/03/02 20:19:55 Can you take a look at the latest patch, please? :
67 fakeEvents = fakeEvents.map(eventFromPair);
68
69 // We don't have access to the values stored in the histogram, so we check
70 // for equality in the summary statistics.
71 let values = runWebrtcRenderingMetric(fakeEvents);
72 let hist = values.getHistogramNamed('WebRTCRendering_drift_time');
73 assert.strictEqual(hist.sum, tr.b.Statistics.sum(fakeDriftTimes));
74 assert.strictEqual(hist.numValues, fakeDriftTimes.length);
75 assert.strictEqual(hist.running.min, tr.b.Statistics.min(fakeDriftTimes));
76 assert.strictEqual(hist.running.max, tr.b.Statistics.max(fakeDriftTimes));
77 assert.closeTo(hist.standardDeviation,
78 tr.b.Statistics.stddev(fakeDriftTimes), 1e-2);
79 });
80
81 test('percentBadlyOutOfSync', function() {
82 let values = runWebrtcRenderingMetric(FAKE_EVENTS);
83 let hist =
84 values.getHistogramNamed('WebRTCRendering_percent_badly_out_of_sync');
85 assert.strictEqual(hist.numValues, 1);
86 assert.strictEqual(hist.sum, 0);
87 });
88
89 test('percentOutOfSync', function() {
90 let values = runWebrtcRenderingMetric(FAKE_EVENTS);
91 let hist = values.getHistogramNamed('WebRTCRendering_percent_out_of_sync');
92 assert.strictEqual(hist.numValues, 1);
93 assert.strictEqual(hist.sum, 5);
94 });
95
96 test('fps', function() {
97 let values = runWebrtcRenderingMetric(FAKE_EVENTS);
98 let hist = values.getHistogramNamed('WebRTCRendering_fps');
99 assert.strictEqual(hist.numValues, 1);
100 assert.strictEqual(hist.sum, 60);
101 });
102
103 test('smoothnessScore', function() {
104 let values = runWebrtcRenderingMetric(FAKE_EVENTS);
105 let hist = values.getHistogramNamed('WebRTCRendering_smoothness_score');
106 assert.strictEqual(hist.numValues, 1);
107 assert.strictEqual(hist.sum, 95);
108 });
109
110 test('freezingScore', function() {
111 let values = runWebrtcRenderingMetric(FAKE_EVENTS);
112 let hist = values.getHistogramNamed('WebRTCRendering_freezing_score');
113 assert.strictEqual(hist.numValues, 1);
114 assert.strictEqual(hist.sum, 100);
115 });
116
117 test('renderingLengthError', function() {
118 let values = runWebrtcRenderingMetric(FAKE_EVENTS);
119 let hist =
120 values.getHistogramNamed('WebRTCRendering_rendering_length_error');
121 assert.strictEqual(hist.numValues, 1);
122 assert.closeTo(hist.sum, 36.1, 1e-3);
123 });
124 });
125 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/metrics/webrtc/webrtc_rendering_metric.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698