Skip to content

Commit b8d26b9

Browse files
committed
fix: get timer before golang
1 parent 4f75be4 commit b8d26b9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

testing/testing/benchmark.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,20 @@ func (b *B) StartTimer() {
160160
// runtime.ReadMemStats(&memStats)
161161
// b.startAllocs = memStats.Mallocs
162162
// b.startBytes = memStats.TotalAlloc
163-
b.codspeed.startTimestamp = capi.CurrentTimestamp()
164163
b.start = highPrecisionTimeNow()
165164
b.timerOn = true
166165
// b.loop.i &^= loopPoisonTimer
166+
167+
b.codspeed.startTimestamp = capi.CurrentTimestamp()
167168
}
168169
}
169170

170171
// StopTimer stops timing a test. This can be used to pause the timer
171172
// while performing steps that you don't want to measure.
172173
func (b *B) StopTimer() {
173174
if b.timerOn {
175+
endTimestamp := capi.CurrentTimestamp()
176+
174177
b.duration += highPrecisionTimeSince(b.start)
175178
// runtime.ReadMemStats(&memStats)
176179
// b.netAllocs += memStats.Mallocs - b.startAllocs
@@ -179,7 +182,6 @@ func (b *B) StopTimer() {
179182
// If we hit B.Loop with the timer stopped, fail.
180183
// b.loop.i |= loopPoisonTimer
181184

182-
endTimestamp := capi.CurrentTimestamp()
183185

184186
// Accumulate timestamps for batch submission instead of immediate hook call
185187
b.codspeed.accumulatedStartTimestamps = append(b.codspeed.accumulatedStartTimestamps, b.codspeed.startTimestamp)

0 commit comments

Comments
 (0)