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 inspect | 6 import inspect |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 import traceback | 10 import traceback |
11 | 11 |
12 from telemetry import browser_finder | 12 from telemetry import browser_finder |
13 from telemetry import browser_options | 13 from telemetry import browser_options |
14 from telemetry import multi_page_benchmark | 14 from telemetry import multi_page_benchmark |
| 15 from telemetry import page_interaction |
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 | 19 |
19 def _Discover(start_dir, clazz): | 20 def _Discover(start_dir, clazz): |
20 """Discover all classes in |start_dir| which subclass |clazz|. | 21 """Discover all classes in |start_dir| which subclass |clazz|. |
21 | 22 |
22 Args: | 23 Args: |
23 start_dir: The directory to recursively search. | 24 start_dir: The directory to recursively search. |
24 clazz: The base class to search for. | 25 clazz: The base class to search for. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 import page_sets # pylint: disable=F0401 | 80 import page_sets # pylint: disable=F0401 |
80 print >> sys.stderr, 'Available benchmarks:\n%s\n' % ',\n'.join( | 81 print >> sys.stderr, 'Available benchmarks:\n%s\n' % ',\n'.join( |
81 sorted(benchmarks.keys())) | 82 sorted(benchmarks.keys())) |
82 print >> sys.stderr, 'Available page_sets:\n%s\n' % ',\n'.join( | 83 print >> sys.stderr, 'Available page_sets:\n%s\n' % ',\n'.join( |
83 sorted([os.path.relpath(f) | 84 sorted([os.path.relpath(f) |
84 for f in page_sets.GetAllPageSetFilenames()])) | 85 for f in page_sets.GetAllPageSetFilenames()])) |
85 sys.exit(1) | 86 sys.exit(1) |
86 | 87 |
87 ps = page_set.PageSet.FromFile(args[1]) | 88 ps = page_set.PageSet.FromFile(args[1]) |
88 | 89 |
| 90 _Discover(os.path.dirname(__file__), page_interaction.PageInteraction) |
| 91 |
89 benchmark.CustomizeBrowserOptions(options) | 92 benchmark.CustomizeBrowserOptions(options) |
| 93 benchmark.CustomizeBrowserOptionsForPageSet(ps, options) |
90 possible_browser = browser_finder.FindBrowser(options) | 94 possible_browser = browser_finder.FindBrowser(options) |
91 if not possible_browser: | 95 if not possible_browser: |
92 print >> sys.stderr, """No browser found.\n | 96 print >> sys.stderr, """No browser found.\n |
93 Use --browser=list to figure out which are available.\n""" | 97 Use --browser=list to figure out which are available.\n""" |
94 sys.exit(1) | 98 sys.exit(1) |
95 | 99 |
96 results = multi_page_benchmark.CsvBenchmarkResults(csv.writer(sys.stdout)) | 100 results = multi_page_benchmark.CsvBenchmarkResults(csv.writer(sys.stdout)) |
97 with page_runner.PageRunner(ps) as runner: | 101 with page_runner.PageRunner(ps) as runner: |
98 runner.Run(options, possible_browser, benchmark, results) | 102 runner.Run(options, possible_browser, benchmark, results) |
99 # When using an exact executable, assume it is a reference build for the | 103 # When using an exact executable, assume it is a reference build for the |
100 # purpose of outputting the perf results. | 104 # purpose of outputting the perf results. |
101 results.PrintSummary(options.browser_executable and '_ref' or '') | 105 results.PrintSummary(options.browser_executable and '_ref' or '') |
102 | 106 |
103 if len(results.page_failures): | 107 if len(results.page_failures): |
104 logging.warning('Failed pages: %s', '\n'.join( | 108 logging.warning('Failed pages: %s', '\n'.join( |
105 [failure['page'].url for failure in results.page_failures])) | 109 [failure['page'].url for failure in results.page_failures])) |
106 return min(255, len(results.page_failures)) | 110 return min(255, len(results.page_failures)) |
OLD | NEW |