Canonical guidance

Use when

Avoid

Preferred pattern

func BenchmarkParse(b *testing.B) {
	for i := 0; i < b.N; i++ {
		_ = Parse(input)
	}
}

Anti-pattern

Explanation: This anti-pattern is common because benchmark harness code is easy to mix with setup, but that inflates numbers and makes comparisons meaningless.

Why

Related pages

Sources