We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 073862e commit 730da69Copy full SHA for 730da69
src/testing/benchmark.go
@@ -159,6 +159,7 @@ func (b *B) ReportAllocs() {
159
160
// runN runs a single benchmark for the specified number of iterations.
161
func (b *B) runN(n int) {
162
+ b.runCleanup() // start fresh in the next iteration
163
b.N = n
164
runtime.GC()
165
b.ResetTimer()
@@ -457,6 +458,7 @@ func (b *B) Run(name string, f func(b *B)) bool {
457
458
// Only process sub-benchmarks, if any.
459
sub.hasSub = true
460
}
461
+ defer sub.runCleanup() // make sure all cleanups are run, even when panicking
462
if sub.run1() {
463
sub.run()
464
0 commit comments