OLD | NEW |
---|---|
(Empty) | |
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 """Seek performance testing for <video>. | |
7 | |
8 Calculates the short and long seek times for different video formats on | |
9 different network constraints. | |
10 """ | |
11 | |
12 import logging | |
13 import os | |
14 | |
15 import pyauto_media | |
16 import pyauto_utils | |
17 | |
18 import cns_test_base | |
19 import worker_thread | |
20 | |
21 # Number of threads to use during testing. | |
22 _TEST_THREADS = 3 | |
23 | |
24 # HTML test path; relative to src/chrome/test/data. | |
25 _TEST_HTML_PATH = os.path.join('media', 'html', 'media_seek.html') | |
26 | |
27 # The media files used for testing. | |
28 # Path under CNS root folder (pyauto_private/media). | |
29 _TEST_VIDEOS = [ | |
30 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. :)
| |
31 ['crowd1080.webm', 'crowd720.webm', 'crowd480.webm', 'crowd360.webm']] | |
32 | |
33 # Constraints to run tests on. | |
34 _TESTS_TO_RUN = [ | |
35 cns_test_base.Cable, | |
36 cns_test_base.LowMediumNone, | |
37 cns_test_base.Cable, | |
38 cns_test_base.Wifi, | |
39 cns_test_base.DSL, | |
40 cns_test_base.NoConstraints] | |
41 | |
42 | |
43 class SeekWorkerThread(worker_thread.WorkerThread): | |
44 """Worker thread. Runs a test for each task in the queue.""" | |
45 | |
46 def RunTask(self, unique_url, task): | |
47 """Runs the specific task on the url given. | |
48 | |
49 It is assumed that a tab with the unique_url is already loaded. | |
50 Args: | |
51 unique_url: A unique identifier of the test page. | |
52 task: A (series_name, settings, file_name) tuple to run the test on. | |
53 """ | |
54 series_name, settings, file_name = task | |
55 | |
56 video_url = cns_test_base.GetFileURL( | |
57 file_name, bandwidth=settings[0], latency=settings[1], | |
58 loss=settings[2], new_port=False) | |
59 | |
60 uncached_seeks = [] | |
61 cached_seeks = [] | |
62 cached_after_seek = [] | |
63 | |
64 # Start the test! | |
65 self.CallJavascriptFunc('startTest', [video_url], unique_url) | |
66 | |
67 logging.debug('Running perf test for %s.', video_url) | |
68 self.WaitUntil(self.GetDOMValue, args=['endTest', unique_url], | |
69 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.
| |
70 | |
71 error_msg = self.GetDOMValue('errorMsg', unique_url) | |
72 if error_msg: | |
73 logging.error('Error while running the test: %s.' % error_msg) | |
74 else: | |
75 uncached_seeks = [ | |
76 float(value) for value in | |
77 self.GetDOMValue("uncached_seeks.join(',')", unique_url).split(',')] | |
78 cached_seeks = [ | |
79 float(value) for value in | |
80 self.GetDOMValue("cached_seeks.join(',')", unique_url).split(',')] | |
81 cached_after_seek = [ | |
82 float(value) for value in | |
83 self.GetDOMValue("cached_after_seek.join(',')", | |
84 unique_url).split(',')] | |
85 | |
86 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
| |
87 pyauto_utils.PrintPerfResult('seek', 'uncached_' + graph_name, | |
88 uncached_seeks, 'ms') | |
89 pyauto_utils.PrintPerfResult('seek', 'cached_' + graph_name, cached_seeks, | |
90 'ms') | |
91 pyauto_utils.PrintPerfResult('seek', 'cached_after_seek_' + graph_name, | |
92 cached_after_seek, 'ms') | |
93 | |
94 | |
95 class MediaSeekPerfTest(cns_test_base.CNSTestBase): | |
96 """PyAuto test container. See file doc string for more information.""" | |
97 | |
98 def testMediaSeekPerformance(self): | |
99 """Launches HTML test which plays each video and records seek stats.""" | |
100 tasks = cns_test_base.CreateCNSPerfTasks(_TESTS_TO_RUN, _TEST_VIDEOS) | |
101 worker_thread.RunWorkerThreads(self, SeekWorkerThread, tasks, _TEST_THREADS, | |
102 _TEST_HTML_PATH) | |
103 | |
DaleCurtis
2012/04/18 18:57:53
Two lines.
shadi
2012/04/19 04:16:59
Done.
| |
104 if __name__ == '__main__': | |
105 pyauto_media.Main() | |
OLD | NEW |