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

Side by Side Diff: tracing/tracing/metrics/media_metric_test.html

Issue 2996233004: Port a media metric to TBMv2 (Closed)
Patch Set: Throw error if multiple media elements Created 3 years, 3 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/media_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 2017 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/media_metric.html">
11 <link rel="import" href="/tracing/value/histogram_set.html">
12
13 <script>
14 'use strict';
15
16 tr.b.unittest.testSuite(function() {
17 function makeModel(events) {
18 return tr.c.TestUtils.newModelWithEvents([events]);
19 }
20
21 test('mediaMetric_noData', function() {
22 const histograms = new tr.v.HistogramSet();
23 const events = [
24 {name: 'a', args: {}, pid: 52, ts: 524, cat: 'foo', tid: 53, ph: 'B'},
25 {name: 'a', args: {}, pid: 52, ts: 560, cat: 'foo', tid: 53, ph: 'B'}
26 ];
27 tr.metrics.mediaMetric(histograms, makeModel(events));
28 assert.lengthOf(histograms, 0);
29 });
30
31 test('mediaMetric_videoTimeToPlay', function() {
32 const histograms = new tr.v.HistogramSet();
33 const events = [
34 {name: 'WebMediaPlayerImpl::DoLoad', args: {},
35 pid: 52, ts: 524, cat: 'media', tid: 1, ph: 'X'},
36 {name: 'VideoRendererImpl::Render', args: {},
37 pid: 52, ts: 560, cat: 'media', tid: 53, ph: 'X'},
38 {name: 'VideoRendererImpl::Render', args: {},
39 pid: 52, ts: 580, cat: 'media', tid: 53, ph: 'X'},
40 {name: 'thread_name', args: {name: 'CrRendererMain'},
41 pid: 52, ts: 0, cat: '__metadata', tid: 1, ph: 'M'},
42 {name: 'thread_name', args: {name: 'Compositor'},
43 pid: 52, ts: 0, cat: '__metadata', tid: 53, ph: 'M'},
44 ];
45 tr.metrics.mediaMetric(histograms, makeModel(events));
46
47 assert.isDefined(histograms.getHistogramNamed('time_to_video_play'));
48 const ttpValue = histograms.getHistogramNamed('time_to_video_play');
49 const ttpStatistics = ttpValue.running;
50 assert.strictEqual(ttpStatistics.count, 1);
51 assert.closeTo(ttpStatistics.mean, 0.036, 1e-5);
52 assert.closeTo(ttpStatistics.max, 0.036, 1e-5);
53 });
54
55 test('mediaMetric_audioTimeToPlay', function() {
56 const histograms = new tr.v.HistogramSet();
57 const events = [
58 {name: 'thread_name', args: {name: 'CrRendererMain'},
59 pid: 52, ts: 0, cat: '__metadata', tid: 1, ph: 'M'},
60 {name: 'thread_name', args: {name: 'AudioOutputDevice'},
61 pid: 52, ts: 0, cat: '__metadata', tid: 53, ph: 'M'},
62 {name: 'WebMediaPlayerImpl::DoLoad', args: {},
63 pid: 52, ts: 1234, cat: 'media', tid: 1, ph: 'X'},
64 {name: 'AudioRendererImpl::Render', args: {},
65 pid: 52, ts: 4321, cat: 'media', tid: 53, ph: 'X'},
66 ];
67 tr.metrics.mediaMetric(histograms, makeModel(events));
68
69 assert.isDefined(histograms.getHistogramNamed('time_to_audio_play'));
70 const ttpValue = histograms.getHistogramNamed('time_to_audio_play');
71 const ttpStatistics = ttpValue.running;
72 assert.strictEqual(ttpStatistics.count, 1);
73 assert.closeTo(ttpStatistics.mean, 3.087, 1e-5);
74 assert.closeTo(ttpStatistics.max, 3.087, 1e-5);
75 });
76 });
77 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/metrics/media_metric.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698