From ffadb65d3a17452b2bd08951d1bce6b0f6bf65d9 Mon Sep 17 00:00:00 2001 From: Sayan Bhattacharjee Date: Wed, 21 Aug 2019 22:21:31 +0530 Subject: [PATCH] Documentation of basic use of DenseRange. (#855) Documentation of basic use of `DenseRange` was added to README.md. --- AUTHORS | 1 + CONTRIBUTORS | 1 + README.md | 16 ++++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/AUTHORS b/AUTHORS index 15418631..c5e5c0c4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -44,6 +44,7 @@ Ori Livneh Paul Redmond Radoslav Yovchev Roman Lebedev +Sayan Bhattacharjee Shuo Chen Steinar H. Gunderson Stripe, Inc. diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 167165f4..5be6dc48 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -65,6 +65,7 @@ Raul Marin Ray Glover Robert Guo Roman Lebedev +Sayan Bhattacharjee Shuo Chen Tobias Ulvgård Tom Madams diff --git a/README.md b/README.md index e9fbe130..eb9374c2 100644 --- a/README.md +++ b/README.md @@ -422,6 +422,22 @@ BENCHMARK(BM_memcpy)->RangeMultiplier(2)->Range(8, 8<<10); ``` Now arguments generated are [ 8, 16, 32, 64, 128, 256, 512, 1024, 2k, 4k, 8k ]. +The preceding code shows a method of defining a sparse range. The following +example shows a method of defining a dense range. It is then used to benchmark +the performance of `std::vector` initialization for uniformly increasing sizes. + +```c++ +static void BM_DenseRange(benchmark::State& state) { + for(auto _ : state) { + std::vector v(state.range(0), state.range(0)); + benchmark::DoNotOptimize(v.data()); + benchmark::ClobberMemory(); + } +} +BENCHMARK(BM_DenseRange)->DenseRange(0, 1024, 128); +``` +Now arguments generated are [ 0, 128, 256, 384, 512, 640, 768, 896, 1024 ]. + You might have a benchmark that depends on two or more inputs. For example, the following code defines a family of benchmarks for measuring the speed of set insertion.