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

Side by Side Diff: tools/perf/fetch_benchmark_deps.py

Issue 1568103002: Update tools/perf to use cloud_storage from catapult. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Erik comment Created 4 years, 11 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 #!/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 os 8 import os
9 import sys 9 import sys
10 10
11 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'telemetry')) 11 from core import path_util
12 12
13 path_util.AddCatapultBaseToPath()
13 from catapult_base import cloud_storage 14 from catapult_base import cloud_storage
15
16 path_util.AddTelemetryToPath()
14 from telemetry import benchmark_runner 17 from telemetry import benchmark_runner
15 18
16 19
17 def _GetPerfDir(*subdirs):
18 perf_dir = os.path.realpath(os.path.dirname(__file__))
19 return os.path.join(perf_dir, *subdirs)
20
21
22 def GetChromiumDir():
23 return _GetPerfDir(os.path.pardir, os.path.pardir, os.path.pardir)
24
25
26 def _FetchDependenciesIfNeeded(story_set): 20 def _FetchDependenciesIfNeeded(story_set):
27 """ Download files needed by a user story set. """ 21 """ Download files needed by a user story set. """
28 # Download files in serving_dirs. 22 # Download files in serving_dirs.
29 serving_dirs = story_set.serving_dirs 23 serving_dirs = story_set.serving_dirs
30 for directory in serving_dirs: 24 for directory in serving_dirs:
31 cloud_storage.GetFilesInDirectoryIfChanged(directory, story_set.bucket) 25 cloud_storage.GetFilesInDirectoryIfChanged(directory, story_set.bucket)
32 26
33 # Download WPR files. 27 # Download WPR files.
34 if any(not story.is_local for story in story_set): 28 if any(not story.is_local for story in story_set):
35 story_set.wpr_archive_info.DownloadArchivesIfNeeded() 29 story_set.wpr_archive_info.DownloadArchivesIfNeeded()
(...skipping 14 matching lines...) Expand all
50 if directory == os.path.abspath(os.sep): 44 if directory == os.path.abspath(os.sep):
51 raise ValueError('Trying to serve root directory from HTTP server.') 45 raise ValueError('Trying to serve root directory from HTTP server.')
52 for dirpath, _, filenames in os.walk(directory): 46 for dirpath, _, filenames in os.walk(directory):
53 for filename in filenames: 47 for filename in filenames:
54 path_name, extension = os.path.splitext( 48 path_name, extension = os.path.splitext(
55 os.path.join(dirpath, filename)) 49 os.path.join(dirpath, filename))
56 if extension == '.sha1': 50 if extension == '.sha1':
57 deps.add(path_name) 51 deps.add(path_name)
58 52
59 # Return relative paths. 53 # Return relative paths.
60 prefix_len = len(os.path.realpath(GetChromiumDir())) + 1 54 prefix_len = len(os.path.realpath(path_util.GetChromiumSrcDir())) + 1
61 return [dep[prefix_len:] for dep in deps if dep] 55 return [dep[prefix_len:] for dep in deps if dep]
62 56
63 57
64 def _show_usage(): 58 def _show_usage():
65 print ('Usage: %s benchmark_name\n' 59 print ('Usage: %s benchmark_name\n'
66 'Fetch the dependencies of benchmark_name.' % sys.argv[0]) 60 'Fetch the dependencies of benchmark_name.' % sys.argv[0])
67 61
68 62
69 def main(output=sys.stdout): 63 def main(output=sys.stdout):
70 config = benchmark_runner.ProjectConfig( 64 config = benchmark_runner.ProjectConfig(
71 top_level_dir=_GetPerfDir(), 65 top_level_dir=path_util.GetPerfDir(),
72 benchmark_dirs=[_GetPerfDir('benchmarks')]) 66 benchmark_dirs=[path_util.GetPerfDir('benchmarks')])
eakuefner 2016/01/08 19:54:54 While you're at it, maybe you can consider adding
aiolos (Not reviewing) 2016/01/08 20:25:27 Done.
73 67
74 name = sys.argv[1] 68 name = sys.argv[1]
75 benchmark = benchmark_runner.GetBenchmarkByName(name, config) 69 benchmark = benchmark_runner.GetBenchmarkByName(name, config)
76 if not benchmark: 70 if not benchmark:
77 raise ValueError('No such benchmark: %s' % name) 71 raise ValueError('No such benchmark: %s' % name)
78 72
79 # Download files according to specified benchmark. 73 # Download files according to specified benchmark.
80 story_set = benchmark().CreateStorySet(None) 74 story_set = benchmark().CreateStorySet(None)
81 75
82 _FetchDependenciesIfNeeded(story_set) 76 _FetchDependenciesIfNeeded(story_set)
83 77
84 # Print files downloaded. 78 # Print files downloaded.
85 deps = _EnumerateDependencies(story_set) 79 deps = _EnumerateDependencies(story_set)
86 for dep in deps: 80 for dep in deps:
87 print >> output, dep 81 print >> output, dep
88 82
89 83
90 if __name__ == '__main__': 84 if __name__ == '__main__':
91 if len(sys.argv) != 2 or sys.argv[1][0] == '-': 85 if len(sys.argv) != 2 or sys.argv[1][0] == '-':
92 _show_usage() 86 _show_usage()
93 else: 87 else:
94 main() 88 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698