aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/benchmark.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/testing/benchmark.go b/src/testing/benchmark.go
index 437c2ec741..fbd82beb84 100644
--- a/src/testing/benchmark.go
+++ b/src/testing/benchmark.go
@@ -483,12 +483,14 @@ func (b *B) loopSlowPath() bool {
// the timer so cleanup code is not measured.
//
// Within the body of a "for b.Loop() { ... }" loop, arguments to and
-// results from function calls within the loop are kept alive, preventing
-// the compiler from fully optimizing away the loop body. Currently, this is
-// implemented by disabling inlining of functions called in a b.Loop loop.
-// This applies only to calls syntactically between the curly braces of the loop,
-// and the loop condition must be written exactly as "b.Loop()". Optimizations
-// are performed as usual in any functions called by the loop.
+// results from function calls and assignment receivers within the loop are kept
+// alive, preventing the compiler from fully optimizing away the loop body.
+// Currently, this is implemented as a compiler transformation that wraps such
+// variables with a runtime.KeepAlive intrinsic call. The compiler can recursively
+// walk the body of for, if statments, the cases of switch, select statments
+// and bracket-braced blocks. This applies only to statements syntactically between
+// the curly braces of the loop, and the loop condition must be written exactly
+// as "b.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.