Chromium Code Reviews| Index: chrome/test/functional/media/media_seek_perf.py |
| diff --git a/chrome/test/functional/media/media_seek_perf.py b/chrome/test/functional/media/media_seek_perf.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..17b1162cc61a4c58a41b384ee57e7d3b80d3ef02 |
| --- /dev/null |
| +++ b/chrome/test/functional/media/media_seek_perf.py |
| @@ -0,0 +1,105 @@ |
| +#!/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. |
| + |
| +"""Seek performance testing for <video>. |
| + |
| +Calculates the short and long seek times for different video formats on |
| +different network constraints. |
| +""" |
| + |
| +import logging |
| +import os |
| + |
| +import pyauto_media |
| +import pyauto_utils |
| + |
| +import cns_test_base |
| +import worker_thread |
| + |
| +# Number of threads to use during testing. |
| +_TEST_THREADS = 3 |
| + |
| +# HTML test path; relative to src/chrome/test/data. |
| +_TEST_HTML_PATH = os.path.join('media', 'html', 'media_seek.html') |
| + |
| +# The media files used for testing. |
| +# Path under CNS root folder (pyauto_private/media). |
| +_TEST_VIDEOS = [ |
| + os.path.join('crowd', name) for name in |
|
DaleCurtis
2012/04/18 18:57:53
Not sure about this indenting, but if pylint doesn
shadi
2012/04/19 04:16:59
gpylint does not complain. :)
|
| + ['crowd1080.webm', 'crowd720.webm', 'crowd480.webm', 'crowd360.webm']] |
| + |
| +# Constraints to run tests on. |
| +_TESTS_TO_RUN = [ |
| + cns_test_base.Cable, |
| + cns_test_base.LowMediumNone, |
| + cns_test_base.Cable, |
| + cns_test_base.Wifi, |
| + cns_test_base.DSL, |
| + cns_test_base.NoConstraints] |
| + |
| + |
| +class SeekWorkerThread(worker_thread.WorkerThread): |
| + """Worker thread. Runs a test for each task in the queue.""" |
| + |
| + def RunTask(self, unique_url, task): |
| + """Runs the specific task on the url given. |
| + |
| + It is assumed that a tab with the unique_url is already loaded. |
| + Args: |
| + unique_url: A unique identifier of the test page. |
| + task: A (series_name, settings, file_name) tuple to run the test on. |
| + """ |
| + series_name, settings, file_name = task |
| + |
| + video_url = cns_test_base.GetFileURL( |
| + file_name, bandwidth=settings[0], latency=settings[1], |
| + loss=settings[2], new_port=False) |
| + |
| + uncached_seeks = [] |
| + cached_seeks = [] |
| + cached_after_seek = [] |
| + |
| + # Start the test! |
| + self.CallJavascriptFunc('startTest', [video_url], unique_url) |
| + |
| + logging.debug('Running perf test for %s.', video_url) |
| + self.WaitUntil(self.GetDOMValue, args=['endTest', unique_url], |
| + retry_sleep=1, timeout=500, debug=False) |
|
DaleCurtis
2012/04/18 18:57:53
Big timeout?
shadi
2012/04/19 04:16:59
On slow connections, I got seeks in > 25 secs. So
DaleCurtis
2012/04/19 19:42:10
Add a comment about the timeout then.
|
| + |
| + error_msg = self.GetDOMValue('errorMsg', unique_url) |
| + if error_msg: |
| + logging.error('Error while running the test: %s.' % error_msg) |
| + else: |
| + uncached_seeks = [ |
| + float(value) for value in |
| + self.GetDOMValue("uncached_seeks.join(',')", unique_url).split(',')] |
| + cached_seeks = [ |
| + float(value) for value in |
| + self.GetDOMValue("cached_seeks.join(',')", unique_url).split(',')] |
| + cached_after_seek = [ |
| + float(value) for value in |
| + self.GetDOMValue("cached_after_seek.join(',')", |
| + unique_url).split(',')] |
| + |
| + graph_name = series_name +'_' + os.path.basename(file_name) |
|
DaleCurtis
2012/04/18 18:57:53
s/+'/+ '/
Gpylint :)
shadi
2012/04/19 04:16:59
I do run gpylint, but it is not catching this, nor
|
| + pyauto_utils.PrintPerfResult('seek', 'uncached_' + graph_name, |
| + uncached_seeks, 'ms') |
| + pyauto_utils.PrintPerfResult('seek', 'cached_' + graph_name, cached_seeks, |
| + 'ms') |
| + pyauto_utils.PrintPerfResult('seek', 'cached_after_seek_' + graph_name, |
| + cached_after_seek, 'ms') |
| + |
| + |
| +class MediaSeekPerfTest(cns_test_base.CNSTestBase): |
| + """PyAuto test container. See file doc string for more information.""" |
| + |
| + def testMediaSeekPerformance(self): |
| + """Launches HTML test which plays each video and records seek stats.""" |
| + tasks = cns_test_base.CreateCNSPerfTasks(_TESTS_TO_RUN, _TEST_VIDEOS) |
| + worker_thread.RunWorkerThreads(self, SeekWorkerThread, tasks, _TEST_THREADS, |
| + _TEST_HTML_PATH) |
| + |
|
DaleCurtis
2012/04/18 18:57:53
Two lines.
shadi
2012/04/19 04:16:59
Done.
|
| +if __name__ == '__main__': |
| + pyauto_media.Main() |