| Index: tools/chrome_remote_control/examples/rendering_microbenchmark_test.py
|
| diff --git a/tools/chrome_remote_control/examples/rendering_microbenchmark_test.py b/tools/chrome_remote_control/examples/rendering_microbenchmark_test.py
|
| new file mode 100755
|
| index 0000000000000000000000000000000000000000..01220b548c4463d52d6c7ae714cb4d098c4d5721
|
| --- /dev/null
|
| +++ b/tools/chrome_remote_control/examples/rendering_microbenchmark_test.py
|
| @@ -0,0 +1,76 @@
|
| +#!/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.
|
| +import os
|
| +import re
|
| +import sys
|
| +import time
|
| +import optparse
|
| +
|
| +sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
|
| +
|
| +import chrome_remote_control
|
| +
|
| +def Main(args):
|
| + parser = chrome_remote_control.BrowserOptions.CreateParser(
|
| + "rendering_microbenchmark_test.py <sitelist>")
|
| + # TODO(nduca): Add test specific options here, if any.
|
| + options, args = parser.parse_args()
|
| + if len(args) != 1:
|
| + parser.print_usage()
|
| + return 255
|
| +
|
| + urls = []
|
| + with open(args[0], "r") as f:
|
| + for url in f.readlines():
|
| + url = url.strip()
|
| + if not re.match("(.+)://", url):
|
| + url = "http://%s" % url
|
| + urls.append(url)
|
| +
|
| + options.extra_browser_args.append("--enable-gpu-benchmarking")
|
| + browser_to_create = chrome_remote_control.FindBestPossibleBrowser(options)
|
| + if not browser_to_create:
|
| + sys.stderr.write("No browser found! Supported types: %s" %
|
| + chrome_remote_control.GetAllAvailableBrowserTypes())
|
| + return 255
|
| + with browser_to_create.Create() as b:
|
| + with b.ConnectToNthTab(0) as tab:
|
| + # Check browser for benchmark API. Can only be done on non-chrome URLs.
|
| + tab.BeginToLoadURL("http://www.google.com")
|
| + tab.WaitForDocumentReadyStateToBeComplete()
|
| + if tab.runtime.Evaluate("window.chrome.gpuBenchmarking === undefined"):
|
| + print "Browser does not support gpu benchmarks API."
|
| + return 255
|
| +
|
| + if tab.runtime.Evaluate(
|
| + "window.chrome.gpuBenchmarking.runRenderingBenchmarks === undefined"):
|
| + print "Browser does not support rendering benchmarks API."
|
| + return 255
|
| +
|
| + # Run the test. :)
|
| + first_line = []
|
| + def DumpResults(results):
|
| + if len(first_line) == 0:
|
| + cols = ["url"]
|
| + for r in results:
|
| + cols.append(r["benchmark"])
|
| + print ",".join(cols)
|
| + first_line.append(0)
|
| + cols = [u]
|
| + for r in results:
|
| + cols.append(str(r["result"]))
|
| + print ",".join(cols)
|
| +
|
| + for u in urls:
|
| + tab.BeginToLoadURL(u)
|
| + tab.WaitForDocumentReadyStateToBeInteractiveOrBetter()
|
| + results = tab.runtime.Evaluate(
|
| + "window.chrome.gpuBenchmarking.runRenderingBenchmarks();")
|
| + DumpResults(results)
|
| +
|
| + return 0
|
| +
|
| +if __name__ == "__main__":
|
| + sys.exit(Main(sys.argv))
|
|
|