Skip to content

Commit 9816e99

Browse files
committed
fix(bench): prevent compiler from hoisting fibonacci call out of loop
1 parent 2d866ec commit 9816e99

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

examples/google_benchmark_cmake/fibonacci_bench.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ BENCHMARK(BM_FibonacciRecursive)->Arg(35)->MinTime(5);
2020
static void BM_FibonacciRecursive_Darwin(benchmark::State& state) {
2121
int n = static_cast<int>(state.range(0));
2222
for (auto _ : state) {
23+
benchmark::DoNotOptimize(n);
2324
uint64_t result = fibonacci_recursive(n);
2425
benchmark::DoNotOptimize(result);
2526
}

0 commit comments

Comments
 (0)