Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: tools/telemetry/telemetry/benchmark_runner.py

Issue 1244223002: Create classes_util API, change discover to return a list instead of a dict. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 difflib 10 import difflib
11 import hashlib 11 import hashlib
12 import inspect 12 import inspect
13 import json 13 import json
14 import os 14 import os
15 import sys 15 import sys
16 16
17 from telemetry import benchmark 17 from telemetry import benchmark
18 from telemetry.core import discover
19 from telemetry import decorators 18 from telemetry import decorators
20 from telemetry.internal.browser import browser_finder 19 from telemetry.internal.browser import browser_finder
21 from telemetry.internal.browser import browser_options 20 from telemetry.internal.browser import browser_options
22 from telemetry.internal.util import command_line 21 from telemetry.internal.util import command_line
22 from telemetry.util import classes_util
23 23
24 24
25 def PrintBenchmarkList(benchmarks, possible_browser, output_pipe=sys.stdout): 25 def PrintBenchmarkList(benchmarks, possible_browser, output_pipe=sys.stdout):
26 """ Print benchmarks that are not filtered in the same order of benchmarks in 26 """ Print benchmarks that are not filtered in the same order of benchmarks in
27 the |benchmarks| list. 27 the |benchmarks| list.
28 28
29 Args: 29 Args:
30 benchmarks: the list of benchmarks to be printed (in the same order of the 30 benchmarks: the list of benchmarks to be printed (in the same order of the
31 list). 31 list).
32 possible_browser: the possible_browser instance that's used for checking 32 possible_browser: the possible_browser instance that's used for checking
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 yield cls 284 yield cls
285 285
286 def _MatchingCommands(string): 286 def _MatchingCommands(string):
287 return [command for command in _Commands() 287 return [command for command in _Commands()
288 if command.Name().startswith(string)] 288 if command.Name().startswith(string)]
289 289
290 @decorators.Cache 290 @decorators.Cache
291 def _Benchmarks(environment): 291 def _Benchmarks(environment):
292 benchmarks = [] 292 benchmarks = []
293 for search_dir in environment.benchmark_dirs: 293 for search_dir in environment.benchmark_dirs:
294 benchmarks += discover.DiscoverClasses(search_dir, 294 benchmarks += classes_util.DiscoverClasses(search_dir,
295 environment.top_level_dir, 295 environment.top_level_dir,
296 benchmark.Benchmark, 296 benchmark.Benchmark)
297 index_by_class_name=True).values()
298 return benchmarks 297 return benchmarks
299 298
300 def _MatchBenchmarkName(input_benchmark_name, environment, exact_matches=True): 299 def _MatchBenchmarkName(input_benchmark_name, environment, exact_matches=True):
301 def _Matches(input_string, search_string): 300 def _Matches(input_string, search_string):
302 if search_string.startswith(input_string): 301 if search_string.startswith(input_string):
303 return True 302 return True
304 for part in search_string.split('.'): 303 for part in search_string.split('.'):
305 if part.startswith(input_string): 304 if part.startswith(input_string):
306 return True 305 return True
307 return False 306 return False
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 436
438 # Parse and run the command. 437 # Parse and run the command.
439 parser = command.CreateParser() 438 parser = command.CreateParser()
440 command.AddCommandLineArgs(parser, environment) 439 command.AddCommandLineArgs(parser, environment)
441 options, args = parser.parse_args() 440 options, args = parser.parse_args()
442 if commands: 441 if commands:
443 args = args[1:] 442 args = args[1:]
444 options.positional_args = args 443 options.positional_args = args
445 command.ProcessCommandLineArgs(parser, options, environment) 444 command.ProcessCommandLineArgs(parser, options, environment)
446 return command().Run(options) 445 return command().Run(options)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698