Commit 29c5f02
committed
perf(bench): prevent constant-folding of fib input across iterations
The recursive fibonacci benchmarks passed a loop-invariant `n` to
fibonacci_recursive, letting the compiler hoist or constant-fold the
entire computation out of the measurement loop. Marking `n` with
DoNotOptimize forces the input to be treated as opaque on every
iteration, so each call actually executes the recursion.1 parent 476e75c commit 29c5f02
1 file changed
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
0 commit comments