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

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: Use webkitNow() instead of Date(). 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 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Audio Loop Benchmark</title>
5 <style>* { font-family: monospace; }</style>
6 </head>
7 <body>
8 <h1>Audio Loop Benchmark</h1>
9 <p>
10 Benchmark measuring how fast we can continuously repeat a short sound
11 clip. In the ideal scenario we'd have zero latency processing script,
12 seeking back to the beginning of the clip, and resuming audio playback.
13 </p>
14
15 <button onclick="startTest();">Start</button>
16
17 <p>
18 Times Played: <span id="times"></span></span><br>
19 Clip Duration: <span id="clip"></span></span><br>
20 Ideal Duration: <span id="ideal"></span><br>
21 Actual Duration: <span id="actual"></span><br>
22 Average Latency: <span id="average"></span><br>
23 </p>
24
25 <script>
26 var TIMES = 50, averageLatency = 0;
27
28 function getAndClearElement(id) {
29 var elem = document.getElementById(id);
30 elem.innerText = '';
31 return elem;
32 }
33
34 function startTest() {
35 var timesElem = getAndClearElement('times');
36 var clipElem = getAndClearElement('clip');
37 var idealElem = getAndClearElement('ideal');
38 var actualElem = getAndClearElement('actual');
39 var averageElem = getAndClearElement('average');
40 var buttonElem = document.querySelector('button');
41
42 var loopCount = 0, idealDuration = 0, actualDuration = 0;
43 var startTime;
44
45 buttonElem.disabled = true;
46
47 function onLoaded() {
48 idealDuration = Math.round(audio.duration * TIMES * 1000, 0);
49 idealElem.innerText = idealDuration + ' ms';
50 clipElem.innerText = Math.round(audio.duration * 1000, 0) + ' ms';
51 audio.addEventListener('seeked', onLoop);
52 startTime = window.performance.webkitNow();
53 audio.play();
54 }
55
56 var audio = document.createElement('audio');
57 audio.addEventListener('canplaythrough', onLoaded);
58 audio.loop = true;
59 audio.src = '../pink_noise_140ms.wav';
60
61 function onLoop() {
62 ++loopCount;
63 timesElem.innerText = loopCount + '/' + TIMES;
64 if (loopCount == TIMES) {
65 actualDuration =window.performance.webkitNow(); - startTime;
shadi 2012/05/21 22:59:44 Is the semi-colon intentional? Plus, does this wo
DaleCurtis 2012/05/21 23:02:56 Whoops, typos galore! It does work w/o PyAuto, it'
66 actualElem.innerText = actualDuration + ' ms';
67 buttonElem.disabled = false;
68
69 averageLatency = (actualDuration - idealDuration) / loopCount;
70 averageElem.innerText = averageLatency + ' ms';
71
72 // Let the PyAuto test know we're done testing.
73 if (window.domAutomationController)
74 window.domAutomationController.send(true);
75
76 audio.pause();
77 }
78 }
79 }
80 </script>
81 </body>
82 </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