| #!/usr/bin/env vpython |
| # Copyright 2018 The Chromium Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| """Generates perf benchmark sharding maps. |
| |
| We shard our benchmarks across multiple machines, when we run these benchmarks |
| on the buildbot waterfall. This allows us to cut the runtime by the number of |
| devices we shard to. |
| |
| Run -h to see available commands. |
| """ |
| |
| import optparse |
| import sys |
| |
| from core import sharding_map_generator |
| from core import perf_data_generator |
| |
| from telemetry.internal.browser import browser_options |
| |
| |
| def _get_stories_for_benchmark(b): |
| story_list = [] |
| benchmark = b() |
| options = browser_options.BrowserFinderOptions() |
| # Add default values for any extra commandline options |
| # provided by the benchmark. |
| parser = optparse.OptionParser() |
| before, _ = parser.parse_args([]) |
| benchmark.AddBenchmarkCommandLineArgs(parser) |
| after, _ = parser.parse_args([]) |
| for extra_option in dir(after): |
| if extra_option not in dir(before): |
| setattr(options, extra_option, getattr(after, extra_option)) |
| for story in benchmark.CreateStorySet(options).stories: |
| if story.name not in story_list: |
| story_list.append(story.name) |
| return story_list |
| |
| |
| def _include_benchmark(name, shorlist): |
| if not shortlist: |
| return True |
| return name in shortlist |
| |
| |
| if __name__ == '__main__': |
| parser = sharding_map_generator.get_parser() |
| options = parser.parse_args() |
| |
| # Parse args and generate data here to avoid circular dependencies between |
| # sharding_map_generator.py and perf_data_generator.py |
| benchmarks = perf_data_generator.current_benchmarks() |
| |
| shortlist = [] |
| if options.benchmarks: |
| shortlist = options.benchmarks.split(',') |
| |
| benchmarks_data = {} |
| for b in benchmarks: |
| if not _include_benchmark(b.Name(), shortlist): |
| continue |
| benchmarks_data[b.Name()] = { |
| 'repeat': b().options.get('pageset_repeat', 1), |
| 'stories': _get_stories_for_benchmark(b) |
| } |
| |
| sys.exit(sharding_map_generator.main(options, benchmarks_data)) |