OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Parses the command line, discovers the appropriate benchmarks, and runs them. | 5 """Parses the command line, discovers the appropriate benchmarks, and runs them. |
6 | 6 |
7 Handles benchmark configuration, but all the logic for | 7 Handles benchmark configuration, but all the logic for |
8 actually running the benchmark is in Benchmark and PageRunner.""" | 8 actually running the benchmark is in Benchmark and PageRunner.""" |
9 | 9 |
10 import hashlib | 10 import hashlib |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 b = None # Need this to stop pylint from complaining undefined variable. | 62 b = None # Need this to stop pylint from complaining undefined variable. |
63 if any(not issubclass(b, benchmark.Benchmark) for b in benchmarks): | 63 if any(not issubclass(b, benchmark.Benchmark) for b in benchmarks): |
64 assert False, '|benchmarks| param contains non benchmark class: %s' % b | 64 assert False, '|benchmarks| param contains non benchmark class: %s' % b |
65 | 65 |
66 # Align the benchmark names to the longest one. | 66 # Align the benchmark names to the longest one. |
67 format_string = ' %%-%ds %%s' % max(len(b.Name()) for b in benchmarks) | 67 format_string = ' %%-%ds %%s' % max(len(b.Name()) for b in benchmarks) |
68 disabled_benchmarks = [] | 68 disabled_benchmarks = [] |
69 | 69 |
70 print >> output_pipe, 'Available benchmarks %sare:' % ( | 70 print >> output_pipe, 'Available benchmarks %sare:' % ( |
71 'for %s ' % possible_browser.browser_type if possible_browser else '') | 71 'for %s ' % possible_browser.browser_type if possible_browser else '') |
| 72 |
| 73 # Sort the benchmarks by benchmark name. |
| 74 benchmarks = sorted(benchmarks, key=lambda b: b.Name()) |
72 for b in benchmarks: | 75 for b in benchmarks: |
73 if not possible_browser or _IsBenchmarkEnabled(b, possible_browser): | 76 if not possible_browser or _IsBenchmarkEnabled(b, possible_browser): |
74 print >> output_pipe, format_string % (b.Name(), b.Description()) | 77 print >> output_pipe, format_string % (b.Name(), b.Description()) |
75 else: | 78 else: |
76 disabled_benchmarks.append(b) | 79 disabled_benchmarks.append(b) |
77 | 80 |
78 if disabled_benchmarks: | 81 if disabled_benchmarks: |
79 print >> output_pipe, ( | 82 print >> output_pipe, ( |
80 '\nDisabled benchmarks for %s are (force run with -d):' % | 83 '\nDisabled benchmarks for %s are (force run with -d):' % |
81 possible_browser.browser_type) | 84 possible_browser.browser_type) |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 | 396 |
394 # Parse and run the command. | 397 # Parse and run the command. |
395 parser = command.CreateParser() | 398 parser = command.CreateParser() |
396 command.AddCommandLineArgs(parser, environment) | 399 command.AddCommandLineArgs(parser, environment) |
397 options, args = parser.parse_args() | 400 options, args = parser.parse_args() |
398 if commands: | 401 if commands: |
399 args = args[1:] | 402 args = args[1:] |
400 options.positional_args = args | 403 options.positional_args = args |
401 command.ProcessCommandLineArgs(parser, options, environment) | 404 command.ProcessCommandLineArgs(parser, options, environment) |
402 return command().Run(options) | 405 return command().Run(options) |
OLD | NEW |