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

In the benchmark below, why might the compiler optimize away the work and produce a misleadingly fast result, and what is the standard fix?

var sink int func BenchmarkWork(b *testing.B) { for i := 0; i < b.N; i++ { fn(i) } }