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

Unified 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: Cleanup. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/media/html/audio_latency_perf.html
diff --git a/chrome/test/data/media/html/audio_latency_perf.html b/chrome/test/data/media/html/audio_latency_perf.html
new file mode 100644
index 0000000000000000000000000000000000000000..fa5304eb7a3b66dad6332f07731d964f438d30f6
--- /dev/null
+++ b/chrome/test/data/media/html/audio_latency_perf.html
@@ -0,0 +1,108 @@
+<html>
+ <head>
+ <title>Audio Loop Benchmark</title>
+ <style>* { font-family: monospace; }</style>
+ </head>
+ <body>
+ <h1>Audio Loop Benchmark</h1>
+ <p>
+ Benchmark measuring how fast we can continuously repeat a short sound
+ clip. In the ideal scenario we'd have zero latency processing script,
+ seeking back to the beginning of the clip, and resuming audio playback.
+ </p>
+ <p>
+ Using the loop attribute will avoid involving script to seek back to the
+ beginning of the clip, but testing reveals it isn't adding to latency.
+ </p>
+
+ <input id="loop" type="checkbox" />Use loop attribute
+ <button onclick="startTest(document.getElementById('loop').checked);">Start</button>
+
+ <p>
+ Times Played: <span id="times"></span></span><br>
+ Clip Duration: <span id="clip"></span></span><br>
+ Ideal Duration: <span id="ideal"></span><br>
+ Actual Duration: <span id="actual"></span><br>
+ </p>
+
+ <script>
+ var TIMES = 50, loopCount = 0, idealDuration = -1, actualDuration = -1;
+
+ function getAndClearElement(id) {
+ var elem = document.getElementById(id);
+ elem.innerText = '';
+ return elem;
+ }
+
+ function startTest(use_loop) {
+ var timesElem = getAndClearElement('times');
+ var clipElem = getAndClearElement('clip');
+ var idealElem = getAndClearElement('ideal');
+ var actualElem = getAndClearElement('actual');
+ var buttonElem = document.querySelector('button');
+
+ loopCount = 0;
+ var startTime;
+
+ buttonElem.disabled = true;
+
+ function onLoaded() {
+ idealDuration = Math.round(audio.duration * TIMES * 1000, 0);
+ idealElem.innerText = idealDuration + ' ms';
+ clipElem.innerText = Math.round(audio.duration * 1000, 0) + ' ms';
+
+ if (use_loop) {
+ audio.addEventListener('seeked', onLoop);
+ audio.loop = true;
+ } else {
+ audio.addEventListener('ended', onEnded);
+ audio.addEventListener('seeked', onSeeked);
+ }
+ startTime = new Date();
+ audio.play();
+ }
+
+ var audio = document.createElement('audio');
+ audio.addEventListener('canplaythrough', onLoaded);
+ audio.src = "../pink_noise_140ms.wav";
+
+ function onEnded() {
+ ++loopCount;
+ timesElem.innerText = loopCount + '/' + TIMES;
+ if (loopCount == TIMES) {
+ actualDuration = new Date() - startTime;
+ actualElem.innerText = actualDuration + ' ms';
+ buttonElem.disabled = false;
+
+ // Let the PyAuto test know we're done testing.
+ if (window.domAutomationController)
+ window.domAutomationController.send(true);
+ return;
+ }
+
+ audio.currentTime = 0;
+ }
+
+ function onSeeked() {
+ audio.play();
+ }
+
+ function onLoop() {
+ ++loopCount;
+ timesElem.innerText = loopCount + '/' + TIMES;
+ if (loopCount == TIMES) {
+ audio.pause();
+ actualDuration = new Date() - startTime;
+ actualElem.innerText = actualDuration + ' ms';
+ buttonElem.disabled = false;
+
+ // Let the PyAuto test know we're done testing.
+ if (window.domAutomationController)
+ window.domAutomationController.send(true);
+ return;
+ }
shadi 2012/05/17 22:03:37 It seems this code is tha same as onEnded except l
DaleCurtis 2012/05/18 00:23:36 Done.
+ }
+ }
+ </script>
+ </body>
+</html>
« no previous file with comments | « no previous file | chrome/test/data/media/pink_noise_140ms.wav » ('j') | chrome/test/functional/media/audio_latency_perf.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698