Skip to content

Commit b3beed3

Browse files
committed
fix(testing): stop timer before codspeed code
1 parent 4597393 commit b3beed3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

testing/testing/benchmark.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,14 @@ func (b *B) StartTimer() {
167167
// while performing steps that you don't want to measure.
168168
func (b *B) StopTimer() {
169169
if b.timerOn {
170+
b.duration += highPrecisionTimeSince(b.start)
171+
// runtime.ReadMemStats(&memStats)
172+
// b.netAllocs += memStats.Mallocs - b.startAllocs
173+
// b.netBytes += memStats.TotalAlloc - b.startBytes
174+
b.timerOn = false
175+
// If we hit B.Loop with the timer stopped, fail.
176+
// b.loop.i |= loopPoisonTimer
177+
170178
endTimestamp := capi.CurrentTimestamp()
171179
b.codspeed.instrument_hooks.AddBenchmarkTimestamps(b.codspeed.startTimestamp, endTimestamp)
172180

@@ -176,13 +184,6 @@ func (b *B) StopTimer() {
176184
// the number of iterations for this round.
177185
b.codspeedItersPerRound = append(b.codspeedItersPerRound, max(int64(b.N), 1))
178186
b.codspeedTimePerRoundNs = append(b.codspeedTimePerRoundNs, highPrecisionTimeSince(b.start))
179-
b.duration += highPrecisionTimeSince(b.start)
180-
// runtime.ReadMemStats(&memStats)
181-
// b.netAllocs += memStats.Mallocs - b.startAllocs
182-
// b.netBytes += memStats.TotalAlloc - b.startBytes
183-
b.timerOn = false
184-
// If we hit B.Loop with the timer stopped, fail.
185-
// b.loop.i |= loopPoisonTimer
186187
}
187188
}
188189

0 commit comments

Comments
 (0)