Unregister from GCM when the only GCM app is removed
[chromium-blink-merge.git] / chrome / test / data / media / html / audio_latency_perf.html
blob22eb259f46230d41173d9df695c1b56e8394adff
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>
15 <button onclick="startTest();">Start</button>
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>
25 <script>
26 var TIMES = 50, averageLatency = 0;
28 function getAndClearElement(id) {
29 var elem = document.getElementById(id);
30 elem.innerText = '';
31 return elem;
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');
42 var loopCount = 0, idealDuration = 0, actualDuration = 0;
43 var startTime;
45 buttonElem.disabled = true;
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.now();
53 audio.play();
56 var audio = document.createElement('audio');
57 audio.addEventListener('canplaythrough', onLoaded);
58 audio.loop = true;
59 audio.src = '../pink_noise_140ms.wav';
61 function onLoop() {
62 ++loopCount;
63 timesElem.innerText = loopCount + '/' + TIMES;
64 if (loopCount == TIMES) {
65 actualDuration = window.performance.now() - startTime;
66 actualElem.innerText = actualDuration + ' ms';
67 buttonElem.disabled = false;
69 averageLatency = (actualDuration - idealDuration) / loopCount;
70 averageElem.innerText = averageLatency + ' ms';
72 // Let the PyAuto test know we're done testing.
73 if (window.domAutomationController)
74 window.domAutomationController.send(true);
76 audio.pause();
80 </script>
81 </body>
82 </html>