Commit b8591e1c authored by dalecurtis@google.com's avatar dalecurtis@google.com

Add new PyAuto test for measuring audio tag latency.

Values seem stable around ~55ms locally.  Will monitor on the bots to
see if we need to add some additional loops.

BUG=128615
TEST=This fabulous new test!

Review URL: https://chromiumcodereview.appspot.com/10411007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138184 0039d316-1c4b-4281-b951-d872f2087c98
parent cbadb28a
<!DOCTYPE html>
<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>
<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>
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();
}
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();
}
}
}
</script>
</body>
</html>
......@@ -726,6 +726,7 @@
# HTML5 media performance tests.
'AV_PERF': {
'linux': [
'media.audio_latency_perf',
'media.media_constrained_network_perf',
'media.media_stat_perf',
'media.media_seek_perf',
......
#!/usr/bin/env python
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Audio latency performance test.
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.
Performance is recorded as the average latency of N playbacks. I.e., if we play
a clip 50 times and the ideal duration of all playbacks is 1000ms and the total
duration is 1500ms, the recorded result is (1500ms - 1000ms) / 50 == 10ms.
"""
import os
import pyauto_media
import pyauto_utils
import pyauto
# HTML test path; relative to src/chrome/test/data.
_TEST_HTML_PATH = os.path.join('media', 'html', 'audio_latency_perf.html')
class AudioLatencyPerfTest(pyauto.PyUITest):
"""PyAuto test container. See file doc string for more information."""
def testAudioLatency(self):
"""Launches HTML test which runs the audio latency test."""
self.NavigateToURL(self.GetFileURLForDataPath(_TEST_HTML_PATH))
# Block until the test finishes and notifies us.
self.assertTrue(self.ExecuteJavascript('startTest();'))
latency = float(self.GetDOMValue('averageLatency'))
pyauto_utils.PrintPerfResult('audio_latency', 'latency', latency, 'ms')
if __name__ == '__main__':
pyauto_media.Main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment