OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 import os | 5 import os |
6 import re | 6 import re |
7 import sys | 7 import sys |
8 | 8 |
9 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 9 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
10 | 10 |
11 import telemetry | 11 from telemetry.core import browser_finder |
| 12 from telemetry.core import browser_options |
12 | 13 |
13 def Main(args): | 14 def Main(args): |
14 options = telemetry.BrowserOptions() | 15 options = browser_options.BrowserOptions() |
15 parser = options.CreateParser('rendering_microbenchmark_test.py <sitelist>') | 16 parser = options.CreateParser('rendering_microbenchmark_test.py <sitelist>') |
16 # TODO(nduca): Add test specific options here, if any. | 17 # TODO(nduca): Add test specific options here, if any. |
17 options, args = parser.parse_args(args) | 18 options, args = parser.parse_args(args) |
18 if len(args) != 1: | 19 if len(args) != 1: |
19 parser.print_usage() | 20 parser.print_usage() |
20 return 255 | 21 return 255 |
21 | 22 |
22 urls = [] | 23 urls = [] |
23 with open(args[0], 'r') as f: | 24 with open(args[0], 'r') as f: |
24 for url in f.readlines(): | 25 for url in f.readlines(): |
25 url = url.strip() | 26 url = url.strip() |
26 if not re.match('(.+)://', url): | 27 if not re.match('(.+)://', url): |
27 url = 'http://%s' % url | 28 url = 'http://%s' % url |
28 urls.append(url) | 29 urls.append(url) |
29 | 30 |
30 options.extra_browser_args.append('--enable-gpu-benchmarking') | 31 options.extra_browser_args.append('--enable-gpu-benchmarking') |
31 browser_to_create = telemetry.FindBrowser(options) | 32 browser_to_create = browser_finder.FindBrowser(options) |
32 if not browser_to_create: | 33 if not browser_to_create: |
33 sys.stderr.write('No browser found! Supported types: %s' % | 34 sys.stderr.write('No browser found! Supported types: %s' % |
34 telemetry.GetAllAvailableBrowserTypes(options)) | 35 browser_finder.GetAllAvailableBrowserTypes(options)) |
35 return 255 | 36 return 255 |
36 with browser_to_create.Create() as b: | 37 with browser_to_create.Create() as b: |
37 tab = b.tabs[0] | 38 tab = b.tabs[0] |
38 # Check browser for benchmark API. Can only be done on non-chrome URLs. | 39 # Check browser for benchmark API. Can only be done on non-chrome URLs. |
39 tab.Navigate('http://www.google.com') | 40 tab.Navigate('http://www.google.com') |
40 import time | 41 import time |
41 time.sleep(2) | 42 time.sleep(2) |
42 tab.WaitForDocumentReadyStateToBeComplete() | 43 tab.WaitForDocumentReadyStateToBeComplete() |
43 if tab.EvaluateJavaScript('window.chrome.gpuBenchmarking === undefined'): | 44 if tab.EvaluateJavaScript('window.chrome.gpuBenchmarking === undefined'): |
44 print 'Browser does not support gpu benchmarks API.' | 45 print 'Browser does not support gpu benchmarks API.' |
(...skipping 22 matching lines...) Expand all Loading... |
67 tab.Navigate(u) | 68 tab.Navigate(u) |
68 tab.WaitForDocumentReadyStateToBeInteractiveOrBetter() | 69 tab.WaitForDocumentReadyStateToBeInteractiveOrBetter() |
69 results = tab.EvaluateJavaScript( | 70 results = tab.EvaluateJavaScript( |
70 'window.chrome.gpuBenchmarking.runRenderingBenchmarks();') | 71 'window.chrome.gpuBenchmarking.runRenderingBenchmarks();') |
71 DumpResults(url, results) | 72 DumpResults(url, results) |
72 | 73 |
73 return 0 | 74 return 0 |
74 | 75 |
75 if __name__ == '__main__': | 76 if __name__ == '__main__': |
76 sys.exit(Main(sys.argv[1:])) | 77 sys.exit(Main(sys.argv[1:])) |
OLD | NEW |