blob: ed0f133e0dc9e4713124ba633af49a7ad7f0ce81 [file] [log] [blame]
Eric Fiselierf6e09e52016-08-09 18:56:48 +00001#!/usr/bin/env python
2"""
3compare_bench.py - Compare two benchmarks or their results and report the
4 difference.
5"""
6import sys
7import gbench
8from gbench import util, report
9
10def main():
11 # Parse the command line flags
12 def usage():
13 print('compare_bench.py <test1> <test2> [benchmark options]...')
14 exit(1)
15 if '--help' in sys.argv or len(sys.argv) < 3:
16 usage()
17 tests = sys.argv[1:3]
18 bench_opts = sys.argv[3:]
19 bench_opts = list(bench_opts)
20 # Run the benchmarks and report the results
21 json1 = gbench.util.run_or_load_benchmark(tests[0], bench_opts)
22 json2 = gbench.util.run_or_load_benchmark(tests[1], bench_opts)
23 output_lines = gbench.report.generate_difference_report(json1, json2)
24 print 'Comparing %s to %s' % (tests[0], tests[1])
25 for ln in output_lines:
26 print(ln)
27
28
29if __name__ == '__main__':
30 main()