OLD | NEW |
---|---|
(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 <!-- | |
9 media_metrics uses Chrome trace events to calculate metrics about video | |
10 and audio playback. It is meant to be used for pages with a <video> or | |
11 <audio> element. It is used by videostack-eng@google.com team for | |
12 regression testing. | |
13 | |
14 This metric currently supports the following measurement: | |
15 * time_to_play calculates how long after a video is requested to | |
16 start playing before the video actually starts. If time_to_play | |
17 regresses, then users will click to play videos and then have | |
18 to wait longer before the videos start actually playing. | |
19 | |
20 More measurements are expected to be added in the near future, such as: | |
21 * buffering_time | |
22 * seek_time | |
23 * dropped_frame_count | |
24 | |
25 Please inform crouleau@chromium.org and johnchen@chromium.org about | |
26 changes to this file. | |
27 --> | |
28 | |
29 <link rel="import" href="/tracing/metrics/metric_registry.html"> | |
30 <link rel="import" href="/tracing/model/helpers/chrome_model_helper.html"> | |
31 <link rel="import" href="/tracing/value/histogram.html"> | |
32 | |
33 <script> | |
34 'use strict'; | |
35 | |
36 tr.exportTo('tr.metrics', function() { | |
37 function mediaMetric(histograms, model) { | |
38 let playStart; | |
39 let timeToPlay; | |
40 | |
41 const chromeHelper = model.getOrCreateHelper( | |
42 tr.model.helpers.ChromeModelHelper); | |
43 if (chromeHelper === undefined) return; | |
44 for (const rendererHelper of Object.values(chromeHelper.rendererHelpers)) { | |
45 for (const event of rendererHelper.process.getDescendantEvents()) { | |
benjhayden
2017/08/29 23:17:25
Thanks, this is good, keep going.
Which thread[s]
johnchen
2017/08/30 01:39:19
The code now looks for the events on specific thre
| |
46 if (event.title === 'WebMediaPlayerImpl::DoLoad') { | |
47 if (playStart === undefined) { | |
48 playStart = event.start; | |
49 } | |
50 } else if (event.title === 'VideoRendererImpl::Render' || | |
51 event.title === 'AudioRendererImpl::Render') { | |
52 if (playStart !== undefined && timeToPlay === undefined) { | |
53 timeToPlay = event.start - playStart; | |
54 break; | |
benjhayden
2017/08/29 23:17:25
We try to make metrics as general as possible in o
johnchen
2017/08/30 01:39:19
The Render events are raised for each video frame.
| |
55 } | |
56 } | |
57 } | |
58 if (timeToPlay !== undefined) { | |
59 break; | |
60 } | |
61 } | |
62 | |
63 if (timeToPlay !== undefined) { | |
64 histograms.createHistogram('time_to_play', | |
65 tr.b.Unit.byName.timeDurationInMs_smallerIsBetter, timeToPlay); | |
66 } | |
67 } | |
68 | |
69 tr.metrics.MetricRegistry.register(mediaMetric); | |
70 | |
71 return { | |
72 mediaMetric, | |
73 }; | |
74 }); | |
75 </script> | |
OLD | NEW |