Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 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 | 5 |
| 6 """This module fetches and prints the dependencies given a benchmark.""" | 6 """This module fetches and prints the dependencies given a benchmark.""" |
| 7 | 7 |
| 8 import argparse | |
| 8 import os | 9 import os |
| 9 import sys | 10 import sys |
| 10 | 11 |
| 12 from core import benchmark_finders | |
| 11 from core import path_util | 13 from core import path_util |
| 12 | 14 |
| 13 path_util.AddPyUtilsToPath() | 15 path_util.AddPyUtilsToPath() |
| 14 from py_utils import cloud_storage | 16 from py_utils import cloud_storage |
| 15 | 17 |
| 16 path_util.AddTelemetryToPath() | 18 path_util.AddTelemetryToPath() |
| 17 from telemetry import benchmark_runner | 19 from telemetry import benchmark_runner |
| 18 | 20 |
| 19 from chrome_telemetry_build import chromium_config | 21 from chrome_telemetry_build import chromium_config |
| 20 | 22 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 50 path_name, extension = os.path.splitext( | 52 path_name, extension = os.path.splitext( |
| 51 os.path.join(dirpath, filename)) | 53 os.path.join(dirpath, filename)) |
| 52 if extension == '.sha1': | 54 if extension == '.sha1': |
| 53 deps.add(path_name) | 55 deps.add(path_name) |
| 54 | 56 |
| 55 # Return relative paths. | 57 # Return relative paths. |
| 56 prefix_len = len(os.path.realpath(path_util.GetChromiumSrcDir())) + 1 | 58 prefix_len = len(os.path.realpath(path_util.GetChromiumSrcDir())) + 1 |
| 57 return [dep[prefix_len:] for dep in deps if dep] | 59 return [dep[prefix_len:] for dep in deps if dep] |
| 58 | 60 |
| 59 | 61 |
| 60 def _show_usage(): | 62 def FetchDepsForBenchmark(benchmark): |
| 61 print ('Usage: %s benchmark_name\n' | 63 print 'Fetch dependencies for benchmark %s:' % benchmark.Name() |
|
laszio
2017/06/01 18:48:44
Some autotest tests in Chrome OS relies on the out
| |
| 62 'Fetch the dependencies of benchmark_name.' % sys.argv[0]) | |
| 63 | |
| 64 | |
| 65 def main(output=sys.stdout): | |
| 66 config = chromium_config.ChromiumConfig( | |
| 67 top_level_dir=path_util.GetPerfDir(), | |
| 68 benchmark_dirs=[os.path.join(path_util.GetPerfDir(), 'benchmarks')]) | |
| 69 | |
| 70 name = sys.argv[1] | |
| 71 benchmark = benchmark_runner.GetBenchmarkByName(name, config) | |
| 72 if not benchmark: | |
| 73 raise ValueError('No such benchmark: %s' % name) | |
| 74 | |
| 75 # Download files according to specified benchmark. | 64 # Download files according to specified benchmark. |
| 76 story_set = benchmark().CreateStorySet(None) | 65 story_set = benchmark().CreateStorySet(None) |
| 77 | 66 |
| 78 _FetchDependenciesIfNeeded(story_set) | 67 _FetchDependenciesIfNeeded(story_set) |
| 79 | 68 |
| 80 # Print files downloaded. | 69 # Print files downloaded. |
| 81 deps = _EnumerateDependencies(story_set) | 70 deps = _EnumerateDependencies(story_set) |
| 82 for dep in deps: | 71 for dep in deps: |
| 83 print >> output, dep | 72 print dep |
| 84 | 73 |
| 85 | 74 |
| 75 def main(args): | |
| 76 parser = argparse.ArgumentParser( | |
| 77 description='Fetch the dependencies of perf benchmark(s).') | |
| 78 parser.add_argument('benchmark_name', type=str, nargs='?') | |
| 79 parser.add_argument('--force', '-f', | |
| 80 help=('Force fetching all the benchmarks when ' | |
| 81 'benchmark_name is not specified'), | |
| 82 action='store_true', default=False) | |
| 83 | |
| 84 options = parser.parse_args(args) | |
| 85 | |
| 86 if options.benchmark_name: | |
| 87 config = chromium_config.ChromiumConfig( | |
| 88 top_level_dir=path_util.GetPerfDir(), | |
| 89 benchmark_dirs=[os.path.join(path_util.GetPerfDir(), 'benchmarks')]) | |
| 90 benchmark = benchmark_runner.GetBenchmarkByName( | |
| 91 options.benchmark_name, config) | |
| 92 if not benchmark: | |
| 93 raise ValueError('No such benchmark: %s' % options.benchmark_name) | |
| 94 FetchDepsForBenchmark(benchmark) | |
| 95 else: | |
| 96 if not options.force: | |
| 97 raw_input( | |
| 98 'No benchmark name is specified. Fetching all benchmark deps. ' | |
| 99 'Press enter to continue...') | |
|
laszio
2017/06/01 18:48:44
Same here. An easy workaround could be printing pr
| |
| 100 for b in benchmark_finders.GetAllBenchmarks(): | |
| 101 FetchDepsForBenchmark(b) | |
| 102 | |
| 86 if __name__ == '__main__': | 103 if __name__ == '__main__': |
| 87 if len(sys.argv) != 2 or sys.argv[1][0] == '-': | 104 main(sys.argv[1:]) |
| 88 _show_usage() | |
| 89 else: | |
| 90 main() | |
| OLD | NEW |