Home | History | Annotate | Download | only in media
      1 #!/usr/bin/env python
      2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
      3 # Use of this source code is governed by a BSD-style license that can be
      4 # found in the LICENSE file.
      5 
      6 """Audio latency performance test.
      7 
      8 Benchmark measuring how fast we can continuously repeat a short sound clip.  In
      9 the ideal scenario we'd have zero latency processing script, seeking back to the
     10 beginning of the clip, and resuming audio playback.
     11 
     12 Performance is recorded as the average latency of N playbacks.  I.e., if we play
     13 a clip 50 times and the ideal duration of all playbacks is 1000ms and the total
     14 duration is 1500ms, the recorded result is (1500ms - 1000ms) / 50 == 10ms.
     15 """
     16 import os
     17 
     18 import pyauto_media
     19 import pyauto_utils
     20 import pyauto
     21 
     22 
     23 # HTML test path; relative to src/chrome/test/data.
     24 _TEST_HTML_PATH = os.path.join('media', 'html', 'audio_latency_perf.html')
     25 
     26 
     27 class AudioLatencyPerfTest(pyauto.PyUITest):
     28   """PyAuto test container.  See file doc string for more information."""
     29 
     30   def testAudioLatency(self):
     31     """Launches HTML test which runs the audio latency test."""
     32     self.NavigateToURL(self.GetFileURLForDataPath(_TEST_HTML_PATH))
     33 
     34     # Block until the test finishes and notifies us.
     35     self.assertTrue(self.ExecuteJavascript('startTest();'))
     36     latency = float(self.GetDOMValue('averageLatency'))
     37     pyauto_utils.PrintPerfResult('audio_latency', 'latency', latency, 'ms')
     38 
     39 
     40 if __name__ == '__main__':
     41   pyauto_media.Main()
     42