1
0
mirror of https://github.com/google/benchmark.git synced 2025-03-13 18:50:11 +08:00

Add docs for ThreadRange. ()

Fixes 
This commit is contained in:
Dominic Hamon 2022-01-12 15:07:31 +00:00 committed by GitHub
parent 0d98dba29d
commit 31e7941796
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -773,6 +773,16 @@ static void BM_MultiThreaded(benchmark::State& state) {
BENCHMARK(BM_MultiThreaded)->Threads(2);
```
To run the benchmark across a range of thread counts, instead of `Threads`, use
`ThreadRange`. This takes two parameters (`min_threads` and `max_threads`) and
runs the benchmark once for values in the inclusive range. For example:
```c++
BENCHMARK(BM_MultiThreaded)->ThreadRange(1, 8);
```
will run `BM_MultiThreaded` with thread counts 1, 2, 4, and 8.
If the benchmarked code itself uses threads and you want to compare it to
single-threaded code, you may want to use real-time ("wallclock") measurements
for latency comparisons: