Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumGobenchmarksSingle-choice MCQ

In a benchmark, you compute a value inside the loop but the compiler optimizes the call away because the result is unused, giving a misleadingly fast result. What is the idiomatic way to prevent this dead-code elimination?

func BenchmarkFib(b *testing.B) { for i := 0; i < b.N; i++ { fib(20) // result discarded } }