Skip to content

Commit 83ac086

Browse files
authored
Add compare_bench.py documentation. Fixes google#309 (google#318)
1 parent a8aa40c commit 83ac086

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ IRC channel: https://freenode.net #googlebenchmark
1111

1212
[Known issues and common problems](#known-issues)
1313

14+
[Additional Tooling Documentation](docs/tools.md)
15+
1416
## Example usage
1517
### Basic usage
1618
Define a function that executes the code to be measured.

docs/tools.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Benchmark Tools
2+
3+
## compare_bench.py
4+
5+
The `compare_bench.py` utility which can be used to compare the result of benchmarks.
6+
The program is invoked like:
7+
8+
``` bash
9+
$ compare_bench.py <old-benchmark> <new-benchmark> [benchmark options]...
10+
```
11+
12+
Where `<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+
14+
The 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
18+
Comparing ./gbench/Inputs/test1_run1.json to ./gbench/Inputs/test1_run2.json
19+
Benchmark Time CPU
20+
----------------------------------------------
21+
BM_SameTimes +0.00 +0.00
22+
BM_2xFaster -0.50 -0.50
23+
BM_2xSlower +1.00 +1.00
24+
BM_10PercentFaster -0.10 -0.10
25+
BM_10PercentSlower +0.10 +0.10
26+
```
27+
28+
When 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.*
32+
RUNNING: test/basic_test --benchmark_filter=BM_empty.*
33+
Run on (4 X 4228.32 MHz CPU s)
34+
2016-08-02 19:21:33
35+
Benchmark Time CPU Iterations
36+
--------------------------------------------------------------------
37+
BM_empty 9 ns 9 ns 79545455
38+
BM_empty/threads:4 4 ns 9 ns 75268816
39+
BM_empty_stop_start 8 ns 8 ns 83333333
40+
BM_empty_stop_start/threads:4 3 ns 8 ns 83333332
41+
RUNNING: test/basic_test --benchmark_filter=BM_empty.*
42+
Run on (4 X 4228.32 MHz CPU s)
43+
2016-08-02 19:21:35
44+
Benchmark Time CPU Iterations
45+
--------------------------------------------------------------------
46+
BM_empty 9 ns 9 ns 76086957
47+
BM_empty/threads:4 4 ns 9 ns 76086956
48+
BM_empty_stop_start 8 ns 8 ns 87500000
49+
BM_empty_stop_start/threads:4 3 ns 8 ns 88607596
50+
Comparing test/basic_test to test/basic_test
51+
Benchmark Time CPU
52+
---------------------------------------------------------
53+
BM_empty +0.00 +0.00
54+
BM_empty/threads:4 +0.00 +0.00
55+
BM_empty_stop_start +0.00 +0.00
56+
BM_empty_stop_start/threads:4 +0.00 +0.00
57+
```
58+
59+
Obviously 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.

0 commit comments

Comments
 (0)