Skip to content
Snippets Groups Projects
Commit 691eefbe authored by Craig Tiller's avatar Craig Tiller
Browse files

Parallel bm_diff

parent f69317cf
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python2.7 args.benchmarks#!/usr/bin/env python2.7
# Copyright 2017, Google Inc. # Copyright 2017, Google Inc.
# All rights reserved. # All rights reserved.
# #
...@@ -41,6 +41,7 @@ import pipes ...@@ -41,6 +41,7 @@ import pipes
import os import os
sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), '..', '..', 'run_tests', 'python_utils')) sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), '..', '..', 'run_tests', 'python_utils'))
import comment_on_pr import comment_on_pr
import jobset
def changed_ratio(n, o): def changed_ratio(n, o):
if float(o) <= .0001: o = 0 if float(o) <= .0001: o = 0
...@@ -101,8 +102,9 @@ argp.add_argument('-t', '--track', ...@@ -101,8 +102,9 @@ argp.add_argument('-t', '--track',
help='Which metrics to track') help='Which metrics to track')
argp.add_argument('-b', '--benchmarks', nargs='+', choices=_AVAILABLE_BENCHMARK_TESTS, default=['bm_cq']) argp.add_argument('-b', '--benchmarks', nargs='+', choices=_AVAILABLE_BENCHMARK_TESTS, default=['bm_cq'])
argp.add_argument('-d', '--diff_base', type=str) argp.add_argument('-d', '--diff_base', type=str)
argp.add_argument('-r', '--repetitions', type=int, default=7) argp.add_argument('-r', '--repetitions', type=int, default=30)
argp.add_argument('-p', '--p_threshold', type=float, default=0.01) argp.add_argument('-p', '--p_threshold', type=float, default=0.01)
argp.add_argument('-j', '--jobs', type=int, default=multiprocessing.cpu_count())
args = argp.parse_args() args = argp.parse_args()
assert args.diff_base assert args.diff_base
...@@ -117,7 +119,7 @@ def avg(lst): ...@@ -117,7 +119,7 @@ def avg(lst):
def make_cmd(cfg): def make_cmd(cfg):
return ['make'] + args.benchmarks + [ return ['make'] + args.benchmarks + [
'CONFIG=%s' % cfg, '-j', '%d' % multiprocessing.cpu_count()] 'CONFIG=%s' % cfg, '-j', '%d' % args.jobs]
def build(): def build():
subprocess.check_call(['git', 'submodule', 'update']) subprocess.check_call(['git', 'submodule', 'update'])
...@@ -135,27 +137,24 @@ def collect1(bm, cfg, ver): ...@@ -135,27 +137,24 @@ def collect1(bm, cfg, ver):
'--benchmark_out_format=json', '--benchmark_out_format=json',
'--benchmark_repetitions=%d' % (args.repetitions) '--benchmark_repetitions=%d' % (args.repetitions)
] ]
print cmd return jobset.JobSpec(cmd, shortname='%s %s %s' % (bm, cfg, ver),
subprocess.check_call(cmd) verbose_success=True)
build() build()
for bm in args.benchmarks: jobset.run(itertools.chain(
collect1(bm, 'opt', 'new') (collect1(bm, 'opt', 'new') for bm in args.benchmarks),
collect1(bm, 'counters', 'new') (collect1(bm, 'counters', 'new') for bm in args.benchmarks),
), maxjobs=args.jobs)
where_am_i = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip() where_am_i = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip()
subprocess.check_call(['git', 'checkout', args.diff_base]) subprocess.check_call(['git', 'checkout', args.diff_base])
try: try:
build() build()
comparables = [] jobset.run(itertools.chain(
for bm in args.benchmarks: (collect1(bm, 'opt', 'new') for bm in args.benchmarks),
try: (collect1(bm, 'counters', 'new') for bm in args.benchmarks),
collect1(bm, 'opt', 'old') ), maxjobs=args.jobs)
collect1(bm, 'counters', 'old')
comparables.append(bm)
except subprocess.CalledProcessError, e:
pass
finally: finally:
subprocess.check_call(['git', 'checkout', where_am_i]) subprocess.check_call(['git', 'checkout', where_am_i])
subprocess.check_call(['git', 'submodule', 'update']) subprocess.check_call(['git', 'submodule', 'update'])
...@@ -201,7 +200,7 @@ class Benchmark: ...@@ -201,7 +200,7 @@ class Benchmark:
benchmarks = collections.defaultdict(Benchmark) benchmarks = collections.defaultdict(Benchmark)
for bm in comparables: for bm in args.benchmarks:
with open('%s.counters.new.json' % bm) as f: with open('%s.counters.new.json' % bm) as f:
js_new_ctr = json.loads(f.read()) js_new_ctr = json.loads(f.read())
with open('%s.opt.new.json' % bm) as f: with open('%s.opt.new.json' % bm) as f:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment