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

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

Issue 84593002: [telemetry] Fix type of of media metric. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | 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
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 }; 89 };
90 90
91 HTMLMediaMetric.prototype.onWillLoop = function(e) { 91 HTMLMediaMetric.prototype.onWillLoop = function(e) {
92 var loopTimer = new Timer(); 92 var loopTimer = new Timer();
93 var metric = this; 93 var metric = this;
94 var loopCount = e.loopCount; 94 var loopCount = e.loopCount;
95 var onEndLoop = function(e) { 95 var onEndLoop = function(e) {
96 var actualDuration = loopTimer.stop(); 96 var actualDuration = loopTimer.stop();
97 var idealDuration = metric.element.duration * loopCount; 97 var idealDuration = metric.element.duration * loopCount;
98 var avg_loop_time = (actualDuration - idealDuration) / loopCount; 98 var avg_loop_time = (actualDuration - idealDuration) / loopCount;
99 metric.metrics['avg_loop_time'] = avg_loop_time.toFixed(3); 99 metric.metrics['avg_loop_time'] =
100 Math.round(avg_loop_time * 1000) / 1000;
100 e.target.removeEventListener('endLoop', onEndLoop); 101 e.target.removeEventListener('endLoop', onEndLoop);
101 }; 102 };
102 this.element.addEventListener('endLoop', onEndLoop); 103 this.element.addEventListener('endLoop', onEndLoop);
103 }; 104 };
104 105
105 HTMLMediaMetric.prototype.appendMetric = function(metric, value) { 106 HTMLMediaMetric.prototype.appendMetric = function(metric, value) {
106 if (!this.metrics[metric]) 107 if (!this.metrics[metric])
107 this.metrics[metric] = []; 108 this.metrics[metric] = [];
108 this.metrics[metric].push(value); 109 this.metrics[metric].push(value);
109 } 110 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 metrics.push(window.__mediaMetrics[i].getSummary()); 201 metrics.push(window.__mediaMetrics[i].getSummary());
201 return metrics; 202 return metrics;
202 } 203 }
203 204
204 window.__globalCounter = 0; 205 window.__globalCounter = 0;
205 window.__mediaMetrics = []; 206 window.__mediaMetrics = [];
206 window.__getMediaMetric = getMediaMetric; 207 window.__getMediaMetric = getMediaMetric;
207 window.__getAllMetrics = getAllMetrics; 208 window.__getAllMetrics = getAllMetrics;
208 window.__createMediaMetricsForDocument = createMediaMetricsForDocument; 209 window.__createMediaMetricsForDocument = createMediaMetricsForDocument;
209 })(); 210 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698