diff options
author | shadi@chromium.org <shadi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-07 04:01:27 +0000 |
---|---|---|
committer | shadi@chromium.org <shadi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-07 04:01:27 +0000 |
commit | c1285ae4272755a44471080616917e31e317d929 (patch) | |
tree | 473b505aac916ce397e885911c32738e88fa6aef /chrome/test/data | |
parent | 3fe2711ac85390463118abb5fd91e66ff12c6a9b (diff) | |
download | chromium_src-c1285ae4272755a44471080616917e31e317d929.zip chromium_src-c1285ae4272755a44471080616917e31e317d929.tar.gz chromium_src-c1285ae4272755a44471080616917e31e317d929.tar.bz2 |
Add audio_latency test with backgound audio playing.
BUG=131426
TEST=None
Review URL: https://chromiumcodereview.appspot.com/10544044
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140950 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/data')
-rw-r--r-- | chrome/test/data/media/html/mixed_audio_latency_perf.html | 94 | ||||
-rw-r--r-- | chrome/test/data/media/pink_noise_20s.wav | 0 |
2 files changed, 94 insertions, 0 deletions
diff --git a/chrome/test/data/media/html/mixed_audio_latency_perf.html b/chrome/test/data/media/html/mixed_audio_latency_perf.html new file mode 100644 index 0000000..0e72e0d --- /dev/null +++ b/chrome/test/data/media/html/mixed_audio_latency_perf.html @@ -0,0 +1,94 @@ +<!DOCTYPE html> +<html> + <head> + <title>Mixed-Audio Loop Benchmark</title> + <style>* { font-family: monospace; }</style> + </head> + <body> + <h1>Mixed-Audio Loop Benchmark </h1> + <p> + Benchmark measuring how fast we can continuously repeat a short sound + clip, while another clip is running in the background. In the ideal + scenario we'd have zero latency processing script, seeking back to the + beginning of the clip, and resuming audio playback. + </p> + + <button onclick="startTest();">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> + Average Latency: <span id="average"></span><br> + </p> + + <script> + // Total time to run the the test is approximately: + // TIMES x (shortclip_duration + latency) =~ 50 x (140 + 50) = 9500ms. + // The background clip should last long enough till the test is finished. + // So a 20sec background clip should be sufficient. + var TIMES = 50, averageLatency = 0; + + function getAndClearElement(id) { + var elem = document.getElementById(id); + elem.innerText = ''; + return elem; + } + + function startTest() { + var timesElem = getAndClearElement('times'); + var clipElem = getAndClearElement('clip'); + var idealElem = getAndClearElement('ideal'); + var actualElem = getAndClearElement('actual'); + var averageElem = getAndClearElement('average'); + var buttonElem = document.querySelector('button'); + + var loopCount = 0, idealDuration = 0, actualDuration = 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'; + audio.addEventListener('seeked', onLoop); + startTime = window.performance.webkitNow(); + audio.play(); + } + + startBackgroundClip(); + var audio = document.createElement('audio'); + audio.addEventListener('canplaythrough', onLoaded); + audio.loop = true; + audio.src = '../pink_noise_140ms.wav'; + + function onLoop() { + ++loopCount; + timesElem.innerText = loopCount + '/' + TIMES; + if (loopCount == TIMES) { + actualDuration = window.performance.webkitNow() - startTime; + actualElem.innerText = actualDuration + ' ms'; + buttonElem.disabled = false; + + averageLatency = (actualDuration - idealDuration) / loopCount; + averageElem.innerText = averageLatency + ' ms'; + + // Let the PyAuto test know we're done testing. + if (window.domAutomationController) + window.domAutomationController.send(true); + + audio.pause(); + } + } + } + + function startBackgroundClip() { + var audio = document.createElement('audio'); + audio.src = '../pink_noise_20s.wav'; + audio.play(); + } + </script> + </body> +</html> diff --git a/chrome/test/data/media/pink_noise_20s.wav b/chrome/test/data/media/pink_noise_20s.wav new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/chrome/test/data/media/pink_noise_20s.wav |