I am using Google Benchmark to benchmark a library. I have the benchmark set up as follows:
for (auto _ : state) {
run_function(first, last, v);
}
What I would like is for v
to be randomly generated every iteration so that I could get a range of benchmark values and obtain the statistics from them. I can do this via:
std::random_device rand_dev;
std::mt19937 generator(rand_dev());
std::uniform_int_distribution<int> distr(min, max);
for (auto _ : state) {
v = distr(generator)
run_function(first, last, v);
}
Some of the functions I am testing are on the order of 10-100ns, so adding in the generator has a significant effect on the results. Is there any way to tell Google Bench to skip a line/block of code?