| 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 | 7 |
| 8 from chrome_remote_control import multi_page_benchmark | 8 from telemetry import multi_page_benchmark |
| 9 | 9 |
| 10 _JS = 'chrome.gpuBenchmarking.printToSkPicture("{0}");' | 10 _JS = 'chrome.gpuBenchmarking.printToSkPicture("{0}");' |
| 11 | 11 |
| 12 class SkPicturePrinter(multi_page_benchmark.MultiPageBenchmark): | 12 class SkPicturePrinter(multi_page_benchmark.MultiPageBenchmark): |
| 13 def AddOptions(self, parser): | 13 def AddOptions(self, parser): |
| 14 parser.add_option('-o', '--outdir', help='Output directory') | 14 parser.add_option('-o', '--outdir', help='Output directory') |
| 15 | 15 |
| 16 def CustomizeBrowserOptions(self, options): | 16 def CustomizeBrowserOptions(self, options): |
| 17 options.extra_browser_args.extend(['--enable-gpu-benchmarking', | 17 options.extra_browser_args.extend(['--enable-gpu-benchmarking', |
| 18 '--no-sandbox']) | 18 '--no-sandbox']) |
| 19 | 19 |
| 20 def MeasurePage(self, page, tab, results): | 20 def MeasurePage(self, page, tab, results): |
| 21 # Derive output path from the URL. The pattern just replaces all special | 21 # Derive output path from the URL. The pattern just replaces all special |
| 22 # characters in the url with underscore. | 22 # characters in the url with underscore. |
| 23 outpath = re.sub('://|[.~!*\:@&=+$,/?%#]', '_', page.url) | 23 outpath = re.sub('://|[.~!*\:@&=+$,/?%#]', '_', page.url) |
| 24 if self.options.outdir is not None: | 24 if self.options.outdir is not None: |
| 25 outpath = os.path.join(self.options.outdir, outpath) | 25 outpath = os.path.join(self.options.outdir, outpath) |
| 26 outpath = os.path.abspath(outpath) | 26 outpath = os.path.abspath(outpath) |
| 27 # Replace win32 path separator char '\' with '\\'. | 27 # Replace win32 path separator char '\' with '\\'. |
| 28 js = _JS.format(outpath.replace('\\', '\\\\')) | 28 js = _JS.format(outpath.replace('\\', '\\\\')) |
| 29 tab.runtime.Evaluate(js) | 29 tab.runtime.Evaluate(js) |
| 30 results.Add('output_path', 'path', outpath) | 30 results.Add('output_path', 'path', outpath) |
| OLD | NEW |