From 31e7941796b55fdc3c9cc649a0b8d1c55ca7b446 Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Wed, 12 Jan 2022 15:07:31 +0000 Subject: [PATCH] Add docs for `ThreadRange`. (#1318) Fixes #1297 --- docs/user_guide.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/user_guide.md b/docs/user_guide.md index 34bea690..b86ef432 100644 --- a/docs/user_guide.md +++ b/docs/user_guide.md @@ -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: