blob: bb639047a6b69741775cfd7f8512c8bc2a8c979a [file] [log] [blame]
#!/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([])
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 not in story_list:
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
# and
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):
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))