Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/testing/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ func (b *B) ReportAllocs() {

// runN runs a single benchmark for the specified number of iterations.
func (b *B) runN(n int) {
b.runCleanup() // start fresh in the next iteration
b.N = n
runtime.GC()
b.ResetTimer()
Expand Down Expand Up @@ -457,6 +458,7 @@ func (b *B) Run(name string, f func(b *B)) bool {
// Only process sub-benchmarks, if any.
sub.hasSub = true
}
defer sub.runCleanup() // make sure all cleanups are run, even when panicking
if sub.run1() {
sub.run()
}
Expand Down
Loading