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 csv | 5 import csv |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import sys | 8 import sys |
9 | 9 |
10 from telemetry import all_page_interactions # pylint: disable=W0611 | 10 from telemetry import all_page_interactions # pylint: disable=W0611 |
11 from telemetry import connection_gone_exception | |
11 from telemetry import browser_finder | 12 from telemetry import browser_finder |
12 from telemetry import browser_options | 13 from telemetry import browser_options |
13 from telemetry import discover | 14 from telemetry import discover |
14 from telemetry import multi_page_benchmark | 15 from telemetry import multi_page_benchmark |
15 from telemetry import page_runner | 16 from telemetry import page_runner |
16 from telemetry import page_set | 17 from telemetry import page_set |
17 | 18 |
18 def Main(benchmark_dir): | 19 def Main(benchmark_dir): |
19 """Turns a MultiPageBenchmark into a command-line program. | 20 """Turns a MultiPageBenchmark into a command-line program. |
20 | 21 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 | 60 |
60 ps = page_set.PageSet.FromFile(args[1]) | 61 ps = page_set.PageSet.FromFile(args[1]) |
61 | 62 |
62 benchmark.CustomizeBrowserOptions(options) | 63 benchmark.CustomizeBrowserOptions(options) |
63 possible_browser = browser_finder.FindBrowser(options) | 64 possible_browser = browser_finder.FindBrowser(options) |
64 if not possible_browser: | 65 if not possible_browser: |
65 print >> sys.stderr, """No browser found.\n | 66 print >> sys.stderr, """No browser found.\n |
66 Use --browser=list to figure out which are available.\n""" | 67 Use --browser=list to figure out which are available.\n""" |
67 sys.exit(1) | 68 sys.exit(1) |
68 | 69 |
69 if options.output_format == 'csv': | 70 retries = 3 |
70 results = multi_page_benchmark.CsvBenchmarkResults(csv.writer(sys.stdout)) | 71 while retries: |
nduca
2012/12/04 04:07:47
This shouldn't be done. We really need to robustly
| |
71 elif options.output_format == 'terminal-block': | 72 try: |
72 results = multi_page_benchmark.TerminalBlockBenchmarkResults(sys.stdout) | 73 if options.output_format == 'csv': |
73 else: | 74 results = multi_page_benchmark.CsvBenchmarkResults( |
74 raise Exception('Invalid --output-format value: "%s". Valid values are ' | 75 csv.writer(sys.stdout)) |
75 '"csv" and "terminal-block".' | 76 elif options.output_format == 'terminal-block': |
76 % options.output_format) | 77 results = multi_page_benchmark.TerminalBlockBenchmarkResults(sys.stdout) |
77 | 78 else: |
78 with page_runner.PageRunner(ps) as runner: | 79 raise Exception('Invalid --output-format value: "%s". Valid values are ' |
79 runner.Run(options, possible_browser, benchmark, results) | 80 '"csv" and "terminal-block".' |
80 # When using an exact executable, assume it is a reference build for the | 81 % options.output_format) |
81 # purpose of outputting the perf results. | 82 with page_runner.PageRunner(ps) as runner: |
82 results.PrintSummary(options.browser_executable and '_ref' or '') | 83 runner.Run(options, possible_browser, benchmark, results) |
84 # When using an exact executable, assume it is a reference build for the | |
85 # purpose of outputting the perf results. | |
86 results.PrintSummary(options.browser_executable and '_ref' or '') | |
87 retries = 0 | |
88 except connection_gone_exception.ConnectionGoneException: | |
89 logging.warning('Lost connection to browser. Retrying.') | |
90 retries -= 1 | |
83 | 91 |
84 if len(results.page_failures): | 92 if len(results.page_failures): |
85 logging.warning('Failed pages: %s', '\n'.join( | 93 logging.warning('Failed pages: %s', '\n'.join( |
86 [failure['page'].url for failure in results.page_failures])) | 94 [failure['page'].url for failure in results.page_failures])) |
87 | 95 |
88 if len(results.skipped_pages): | 96 if len(results.skipped_pages): |
89 logging.warning('Skipped pages: %s', '\n'.join( | 97 logging.warning('Skipped pages: %s', '\n'.join( |
90 [skipped['page'].url for skipped in results.skipped_pages])) | 98 [skipped['page'].url for skipped in results.skipped_pages])) |
91 return min(255, len(results.page_failures)) | 99 return min(255, len(results.page_failures)) |
OLD | NEW |