| 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 |
| 11 import inspect | 11 import inspect |
| 12 import json | 12 import json |
| 13 import os | 13 import os |
| 14 import sys | 14 import sys |
| 15 | 15 |
| 16 from telemetry import benchmark | 16 from telemetry import benchmark |
| 17 from telemetry.core import discover |
| 17 from telemetry import decorators | 18 from telemetry import decorators |
| 18 from telemetry.internal.browser import browser_finder | 19 from telemetry.internal.browser import browser_finder |
| 19 from telemetry.internal.browser import browser_options | 20 from telemetry.internal.browser import browser_options |
| 20 from telemetry.internal.util import command_line | 21 from telemetry.internal.util import command_line |
| 21 from telemetry.util import classes_util | |
| 22 | 22 |
| 23 | 23 |
| 24 def PrintBenchmarkList(benchmarks, possible_browser, output_pipe=sys.stdout): | 24 def PrintBenchmarkList(benchmarks, possible_browser, output_pipe=sys.stdout): |
| 25 """ Print benchmarks that are not filtered in the same order of benchmarks in | 25 """ Print benchmarks that are not filtered in the same order of benchmarks in |
| 26 the |benchmarks| list. | 26 the |benchmarks| list. |
| 27 | 27 |
| 28 Args: | 28 Args: |
| 29 benchmarks: the list of benchmarks to be printed (in the same order of the | 29 benchmarks: the list of benchmarks to be printed (in the same order of the |
| 30 list). | 30 list). |
| 31 possible_browser: the possible_browser instance that's used for checking | 31 possible_browser: the possible_browser instance that's used for checking |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 yield cls | 257 yield cls |
| 258 | 258 |
| 259 def _MatchingCommands(string): | 259 def _MatchingCommands(string): |
| 260 return [command for command in _Commands() | 260 return [command for command in _Commands() |
| 261 if command.Name().startswith(string)] | 261 if command.Name().startswith(string)] |
| 262 | 262 |
| 263 @decorators.Cache | 263 @decorators.Cache |
| 264 def _Benchmarks(environment): | 264 def _Benchmarks(environment): |
| 265 benchmarks = [] | 265 benchmarks = [] |
| 266 for search_dir in environment.benchmark_dirs: | 266 for search_dir in environment.benchmark_dirs: |
| 267 benchmarks += classes_util.DiscoverClasses(search_dir, | 267 benchmarks += discover.DiscoverClasses(search_dir, |
| 268 environment.top_level_dir, | 268 environment.top_level_dir, |
| 269 benchmark.Benchmark) | 269 benchmark.Benchmark, |
| 270 index_by_class_name=True).values() |
| 270 return benchmarks | 271 return benchmarks |
| 271 | 272 |
| 272 def _MatchBenchmarkName(input_benchmark_name, environment, exact_matches=True): | 273 def _MatchBenchmarkName(input_benchmark_name, environment, exact_matches=True): |
| 273 def _Matches(input_string, search_string): | 274 def _Matches(input_string, search_string): |
| 274 if search_string.startswith(input_string): | 275 if search_string.startswith(input_string): |
| 275 return True | 276 return True |
| 276 for part in search_string.split('.'): | 277 for part in search_string.split('.'): |
| 277 if part.startswith(input_string): | 278 if part.startswith(input_string): |
| 278 return True | 279 return True |
| 279 return False | 280 return False |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 | 410 |
| 410 # Parse and run the command. | 411 # Parse and run the command. |
| 411 parser = command.CreateParser() | 412 parser = command.CreateParser() |
| 412 command.AddCommandLineArgs(parser, environment) | 413 command.AddCommandLineArgs(parser, environment) |
| 413 options, args = parser.parse_args() | 414 options, args = parser.parse_args() |
| 414 if commands: | 415 if commands: |
| 415 args = args[1:] | 416 args = args[1:] |
| 416 options.positional_args = args | 417 options.positional_args = args |
| 417 command.ProcessCommandLineArgs(parser, options, environment) | 418 command.ProcessCommandLineArgs(parser, options, environment) |
| 418 return command().Run(options) | 419 return command().Run(options) |
| OLD | NEW |