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 import os | |
6 import re | |
7 import sys | |
8 import time | |
9 import optparse | |
10 | |
11 sys.path.append(os.path.join(os.path.dirname(__file__), "..")) | |
12 | |
13 import chrome_remote_control | |
14 | |
15 def Main(args): | |
16 parser = chrome_remote_control.BrowserOptions.CreateParser( | |
17 "rendering_microbenchmark_test.py <sitelist>") | |
18 # TODO(nduca): Add test specific options here, if any. | |
19 options, args = parser.parse_args() | |
20 if len(args) != 1: | |
21 parser.print_usage() | |
22 return 255 | |
23 | |
24 urls = [] | |
25 with open(args[0], "r") as f: | |
26 for url in f.readlines(): | |
27 url = url.strip() | |
28 if not re.match("(.+)://", url): | |
29 url = "http://%s" % url | |
30 urls.append(url) | |
31 | |
32 options.extra_browser_args.append("--enable-gpu-benchmarking") | |
33 browser_to_create = chrome_remote_control.FindBestPossibleBrowser(options) | |
34 if not browser_to_create: | |
35 sys.stderr.write("No browser found! Supported types: %s" % | |
36 chrome_remote_control.GetAllAvailableBrowserTypes()) | |
37 return 255 | |
38 with browser_to_create.CreateBrowser() as b: | |
dtu
2012/08/27 22:27:27
Create()
| |
39 with b.ConnectToNthTab(0) as tab: | |
40 # Check browser for benchmark API. Can only be done on non-chrome URLs. | |
41 tab.BeginToLoadURL("http://www.google.com") | |
42 tab.WaitForDocumentReadyStateToBeComplete() | |
43 if tab.RuntimeEvaluate("window.chrome.gpuBenchmarking === undefined"): | |
dtu
2012/08/27 22:27:27
tab.runtime.Evaluate() (3 times in this file)
| |
44 print "Browser does not support gpu benchmarks API." | |
45 return 255 | |
46 | |
47 if tab.RuntimeEvaluate( | |
48 "window.chrome.gpuBenchmarking.runRenderingBenchmarks === undefined"): | |
49 print "Browser does not support rendering benchmarks API." | |
50 return 255 | |
51 | |
52 # Run the test. :) | |
53 first_line = [] | |
54 def DumpResults(results): | |
55 if len(first_line) == 0: | |
56 cols = ["url"] | |
57 for r in results: | |
58 cols.append(r["benchmark"]) | |
59 print ",".join(cols) | |
60 first_line.append(0) | |
61 cols = [u] | |
62 for r in results: | |
63 cols.append(str(r["result"])) | |
64 print ",".join(cols) | |
65 | |
66 for u in urls: | |
67 tab.BeginToLoadURL(u) | |
68 tab.WaitForDocumentReadyStateToBeInteractiveOrBetter() | |
69 results = tab.RuntimeEvaluate( | |
70 "window.chrome.gpuBenchmarking.runRenderingBenchmarks();") | |
71 DumpResults(results) | |
72 | |
73 return 0 | |
74 | |
75 if __name__ == "__main__": | |
76 sys.exit(Main(sys.argv)) | |
OLD | NEW |