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

Side by Side Diff: tools/perf/metrics/media.js

Issue 23456012: [Telemetry] Improve logging on media measurement tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix buffering_time sec to ms bug Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/perf/metrics/media.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file contains common utilities to find video/audio elements on a page 5 // This file contains common utilities to find video/audio elements on a page
6 // and collect metrics for each. 6 // and collect metrics for each.
7 7
8 (function() { 8 (function() {
9 // MediaMetric class responsible for collecting metrics on a media element. 9 // MediaMetric class responsible for collecting metrics on a media element.
10 // It attaches required event listeners in order to collect different metrics. 10 // It attaches required event listeners in order to collect different metrics.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 }, false); 56 }, false);
57 this.element.addEventListener('willLoop', function (e) { 57 this.element.addEventListener('willLoop', function (e) {
58 metric.onWillLoop(e); 58 metric.onWillLoop(e);
59 }, false); 59 }, false);
60 } 60 }
61 61
62 HTMLMediaMetric.prototype = new MediaMetricBase(); 62 HTMLMediaMetric.prototype = new MediaMetricBase();
63 HTMLMediaMetric.prototype.constructor = HTMLMediaMetric; 63 HTMLMediaMetric.prototype.constructor = HTMLMediaMetric;
64 64
65 HTMLMediaMetric.prototype.setID = function() { 65 HTMLMediaMetric.prototype.setID = function() {
66 if (this.element.src) 66 if (this.element.id)
67 this.id = this.element.id;
68 else if (this.element.src)
67 this.id = this.element.src.substring(this.element.src.lastIndexOf("/")+1); 69 this.id = this.element.src.substring(this.element.src.lastIndexOf("/")+1);
68 else if (this.element.id)
69 this.id = this.element.id;
70 else 70 else
71 this.id = 'media_' + window.__globalCounter++; 71 this.id = 'media_' + window.__globalCounter++;
72 }; 72 };
73 73
74 HTMLMediaMetric.prototype.onWillPlay = function(e) { 74 HTMLMediaMetric.prototype.onWillPlay = function(e) {
75 this.playbackTimer = new Timer(); 75 this.playbackTimer = new Timer();
76 }; 76 };
77 77
78 HTMLMediaMetric.prototype.onWillSeek = function(e) { 78 HTMLMediaMetric.prototype.onWillSeek = function(e) {
79 var seekLabel = ''; 79 var seekLabel = '';
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // Playing event can fire more than once if seeking. 112 // Playing event can fire more than once if seeking.
113 if (!this.metrics['time_to_play']) 113 if (!this.metrics['time_to_play'])
114 this.metrics['time_to_play'] = this.playbackTimer.stop(); 114 this.metrics['time_to_play'] = this.playbackTimer.stop();
115 }; 115 };
116 116
117 HTMLMediaMetric.prototype.onEnded = function(event) { 117 HTMLMediaMetric.prototype.onEnded = function(event) {
118 var time_to_end = this.playbackTimer.stop() - this.metrics['time_to_play']; 118 var time_to_end = this.playbackTimer.stop() - this.metrics['time_to_play'];
119 // TODO(shadi): Measure buffering time more accurately using events such as 119 // TODO(shadi): Measure buffering time more accurately using events such as
120 // stalled, waiting, progress, etc. This works only when continuous playback 120 // stalled, waiting, progress, etc. This works only when continuous playback
121 // is used. 121 // is used.
122 this.metrics['buffering_time'] = time_to_end - this.element.duration; 122 this.metrics['buffering_time'] = time_to_end - this.element.duration * 1000;
123 }; 123 };
124 124
125 HTMLMediaMetric.prototype.getMetrics = function() { 125 HTMLMediaMetric.prototype.getMetrics = function() {
126 this.metrics['decoded_frame_count'] = this.element.webkitDecodedFrameCount; 126 this.metrics['decoded_frame_count'] = this.element.webkitDecodedFrameCount;
127 this.metrics['dropped_frame_count'] = this.element.webkitDroppedFrameCount; 127 this.metrics['dropped_frame_count'] = this.element.webkitDroppedFrameCount;
128 this.metrics['decoded_video_bytes'] = 128 this.metrics['decoded_video_bytes'] =
129 this.element.webkitVideoDecodedByteCount; 129 this.element.webkitVideoDecodedByteCount;
130 this.metrics['decoded_audio_bytes'] = 130 this.metrics['decoded_audio_bytes'] =
131 this.element.webkitAudioDecodedByteCount; 131 this.element.webkitAudioDecodedByteCount;
132 return this.metrics; 132 return this.metrics;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 for (var i = 0; i < window.__mediaMetrics.length; i++) 188 for (var i = 0; i < window.__mediaMetrics.length; i++)
189 metrics.push(window.__mediaMetrics[i].getSummary()); 189 metrics.push(window.__mediaMetrics[i].getSummary());
190 return metrics; 190 return metrics;
191 } 191 }
192 192
193 window.__globalCounter = 0; 193 window.__globalCounter = 0;
194 window.__mediaMetrics = []; 194 window.__mediaMetrics = [];
195 window.__getAllMetrics = getAllMetrics; 195 window.__getAllMetrics = getAllMetrics;
196 window.__createMediaMetricsForDocument = createMediaMetricsForDocument; 196 window.__createMediaMetricsForDocument = createMediaMetricsForDocument;
197 })(); 197 })();
OLDNEW
« no previous file with comments | « no previous file | tools/perf/metrics/media.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698