blob: f176f74a48f8fdaaf3505746fd91253da25d9e67 [file] [log] [blame] [view]
Eric Fiselier133a7202017-04-18 07:17:20 +00001# Benchmark Tools
2
3## compare_bench.py
4
5The `compare_bench.py` utility which can be used to compare the result of benchmarks.
6The program is invoked like:
7
8``` bash
9$ compare_bench.py <old-benchmark> <new-benchmark> [benchmark options]...
10```
11
12Where `<old-benchmark>` and `<new-benchmark>` either specify a benchmark executable file, or a JSON output file. The type of the input file is automatically detected. If a benchmark executable is specified then the benchmark is run to obtain the results. Otherwise the results are simply loaded from the output file.
13
14The sample output using the JSON test files under `Inputs/` gives:
15
16``` bash
17$ ./compare_bench.py ./gbench/Inputs/test1_run1.json ./gbench/Inputs/test1_run2.json
18Comparing ./gbench/Inputs/test1_run1.json to ./gbench/Inputs/test1_run2.json
19Benchmark Time CPU
20----------------------------------------------
21BM_SameTimes +0.00 +0.00
22BM_2xFaster -0.50 -0.50
23BM_2xSlower +1.00 +1.00
24BM_10PercentFaster -0.10 -0.10
25BM_10PercentSlower +0.10 +0.10
26```
27
28When a benchmark executable is run, the raw output from the benchmark is printed in real time to stdout. The sample output using `benchmark/basic_test` for both arguments looks like:
29
30```
31./compare_bench.py test/basic_test test/basic_test --benchmark_filter=BM_empty.*
32RUNNING: test/basic_test --benchmark_filter=BM_empty.*
33Run on (4 X 4228.32 MHz CPU s)
342016-08-02 19:21:33
35Benchmark Time CPU Iterations
36--------------------------------------------------------------------
37BM_empty 9 ns 9 ns 79545455
38BM_empty/threads:4 4 ns 9 ns 75268816
39BM_empty_stop_start 8 ns 8 ns 83333333
40BM_empty_stop_start/threads:4 3 ns 8 ns 83333332
41RUNNING: test/basic_test --benchmark_filter=BM_empty.*
42Run on (4 X 4228.32 MHz CPU s)
432016-08-02 19:21:35
44Benchmark Time CPU Iterations
45--------------------------------------------------------------------
46BM_empty 9 ns 9 ns 76086957
47BM_empty/threads:4 4 ns 9 ns 76086956
48BM_empty_stop_start 8 ns 8 ns 87500000
49BM_empty_stop_start/threads:4 3 ns 8 ns 88607596
50Comparing test/basic_test to test/basic_test
51Benchmark Time CPU
52---------------------------------------------------------
53BM_empty +0.00 +0.00
54BM_empty/threads:4 +0.00 +0.00
55BM_empty_stop_start +0.00 +0.00
56BM_empty_stop_start/threads:4 +0.00 +0.00
57```
58
59Obviously this example doesn't give any useful output, but it's intended to show the output format when 'compare_bench.py' needs to run benchmarks.