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

Side by Side Diff: chrome/test/data/media/html/audio_latency_perf.html

Issue 10411007: Add new PyAuto test for measuring audio tag latency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR Fixes. Created 8 years, 7 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 | chrome/test/data/media/pink_noise_140ms.wav » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <html>
scherkus (not reviewing) 2012/05/21 21:08:26 <!DOCTYPE html>
DaleCurtis 2012/05/21 22:22:01 Done.
2 <head>
3 <title>Audio Loop Benchmark</title>
4 <style>* { font-family: monospace; }</style>
5 </head>
6 <body>
7 <h1>Audio Loop Benchmark</h1>
8 <p>
9 Benchmark measuring how fast we can continuously repeat a short sound
10 clip. In the ideal scenario we'd have zero latency processing script,
11 seeking back to the beginning of the clip, and resuming audio playback.
12 </p>
13 <p>
14 Using the loop attribute will avoid involving script to seek back to the
15 beginning of the clip, but testing reveals it isn't adding to latency.
16 </p>
17
18 <input id="loop" type="checkbox" />Use loop attribute
scherkus (not reviewing) 2012/05/21 21:08:26 I'd either: a) Remove loop related stuff b) Ha
DaleCurtis 2012/05/21 22:22:01 Done. Made loop the default, cleaned up resulting
19 <button onclick="startTest(document.getElementById('loop').checked);">Start< /button>
20
21 <p>
22 Times Played: <span id="times"></span></span><br>
23 Clip Duration: <span id="clip"></span></span><br>
24 Ideal Duration: <span id="ideal"></span><br>
25 Actual Duration: <span id="actual"></span><br>
26 Average Latency: <span id="average"></span><br>
27 </p>
28
29 <script>
30 var TIMES = 50, averageLatency = 0;
31
32 function getAndClearElement(id) {
33 var elem = document.getElementById(id);
34 elem.innerText = '';
35 return elem;
36 }
37
38 function startTest(use_loop) {
39 var timesElem = getAndClearElement('times');
40 var clipElem = getAndClearElement('clip');
41 var idealElem = getAndClearElement('ideal');
42 var actualElem = getAndClearElement('actual');
43 var averageElem = getAndClearElement('average');
44 var buttonElem = document.querySelector('button');
45
46 var loopCount = 0, idealDuration = 0, actualDuration = 0;
47 var startTime;
48
49 buttonElem.disabled = true;
50
51 function onLoaded() {
52 idealDuration = Math.round(audio.duration * TIMES * 1000, 0);
53 idealElem.innerText = idealDuration + ' ms';
54 clipElem.innerText = Math.round(audio.duration * 1000, 0) + ' ms';
55
56 if (use_loop) {
57 audio.addEventListener('seeked', onLoop);
58 audio.loop = true;
59 } else {
60 audio.addEventListener('ended', onEnded);
61 audio.addEventListener('seeked', onSeeked);
62 }
63 startTime = new Date();
64 audio.play();
65 }
66
67 var audio = document.createElement('audio');
68 audio.addEventListener('canplaythrough', onLoaded);
69 audio.src = '../pink_noise_140ms.wav';
70
71 function isTestDone() {
72 ++loopCount;
73 timesElem.innerText = loopCount + '/' + TIMES;
74 if (loopCount == TIMES) {
75 actualDuration = new Date() - startTime;
76 actualElem.innerText = actualDuration + ' ms';
77 buttonElem.disabled = false;
78
79 averageLatency = (actualDuration - idealDuration) / loopCount;
80 averageElem.innerText = averageLatency + ' ms';
81
82 // Let the PyAuto test know we're done testing.
83 if (window.domAutomationController)
84 window.domAutomationController.send(true);
85
86 return true;
87 }
88
89 return false;
90 }
91
92 function onEnded() {
93 if (!isTestDone())
94 audio.currentTime = 0;
95 }
96
97 function onSeeked() {
98 audio.play();
99 }
100
101 function onLoop() {
102 if (isTestDone())
103 audio.pause();
104 }
105 }
106 </script>
107 </body>
108 </html>
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/media/pink_noise_140ms.wav » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698