From: Junyang Shao Date: Fri, 21 Feb 2025 16:23:36 +0000 (+0000) Subject: testing: fix testing.B.Loop doc on loop condition X-Git-Tag: go1.25rc1~860 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f48b53f0f62c94fac8d835c8e1b48fab5b842bd3;p=gostls13.git testing: fix testing.B.Loop doc on loop condition As mentioned by https://github.com/golang/go/issues/61515#issuecomment-2656656554, the documentation should be relaxed. Change-Id: I9f18301e1a4e4d9a72c9fa0b1132b1ba3cc57b03 Reviewed-on: https://go-review.googlesource.com/c/go/+/651435 LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Pratt Commit-Queue: Junyang Shao --- diff --git a/src/testing/benchmark.go b/src/testing/benchmark.go index 3a7da9e540..6919341ef7 100644 --- a/src/testing/benchmark.go +++ b/src/testing/benchmark.go @@ -426,9 +426,9 @@ func (b *B) loopSlowPath() bool { // The compiler never optimizes away calls to functions within the body of a // "for b.Loop() { ... }" loop. This prevents surprises that can otherwise occur // if the compiler determines that the result of a benchmarked function is -// unused. The loop must be written in exactly this form, and this only applies -// to calls syntactically between the curly braces of the loop. Optimizations -// are performed as usual in any functions called by the loop. +// unused. The loop condition must be written in exactly as "b.Loop()", and this +// only applies to calls syntactically between the curly braces of the loop. +// Optimizations are performed as usual in any functions called by the loop. // // After Loop returns false, b.N contains the total number of iterations that // ran, so the benchmark may use b.N to compute other average metrics.