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 776dabb commit eaca054Copy full SHA for eaca054
src/testing/benchmark.go
@@ -158,6 +158,7 @@ func (b *B) ReportAllocs() {
158
159
// runN runs a single benchmark for the specified number of iterations.
160
func (b *B) runN(n int) {
161
+ b.runCleanup() // start fresh in the next iteration
162
b.N = n
163
b.ResetTimer()
164
b.StartTimer()
@@ -443,6 +444,7 @@ func (b *B) Run(name string, f func(b *B)) bool {
443
444
// Only process sub-benchmarks, if any.
445
sub.hasSub = true
446
}
447
+ defer sub.runCleanup() // make sure all cleanups are run, even when panicking
448
if sub.run1() {
449
sub.run()
450
0 commit comments