@@ -165,19 +165,21 @@ func (b *B) StartTimer() {
165
165
// while performing steps that you don't want to measure.
166
166
func (b * B ) StopTimer () {
167
167
if b .timerOn {
168
- // For b.N loops: This will be called in runN which sets b.N to the number of iterations.
169
- // For b.Loop() loops: loopSlowPath sets b.N to 0 to prevent b.N loops within b.Loop. However, since
170
- // we're starting/stopping the timer for each iteration in the b.Loop() loop, we can use 1 as
171
- // the number of iterations for this round.
172
- b .codspeedItersPerRound = append (b .codspeedItersPerRound , max (int64 (b .N ), 1 ))
173
- b .codspeedTimePerRoundNs = append (b .codspeedTimePerRoundNs , highPrecisionTimeSince (b .start ))
174
- b .duration += highPrecisionTimeSince (b .start )
168
+ timeSinceStart := highPrecisionTimeSince (b .start )
169
+ b .duration += timeSinceStart
175
170
// runtime.ReadMemStats(&memStats)
176
171
// b.netAllocs += memStats.Mallocs - b.startAllocs
177
172
// b.netBytes += memStats.TotalAlloc - b.startBytes
178
173
b .timerOn = false
179
174
// If we hit B.Loop with the timer stopped, fail.
180
175
// b.loop.i |= loopPoisonTimer
176
+
177
+ // For b.N loops: This will be called in runN which sets b.N to the number of iterations.
178
+ // For b.Loop() loops: loopSlowPath sets b.N to 0 to prevent b.N loops within b.Loop. However, since
179
+ // we're starting/stopping the timer for each iteration in the b.Loop() loop, we can use 1 as
180
+ // the number of iterations for this round.
181
+ b .codspeedItersPerRound = append (b .codspeedItersPerRound , max (int64 (b .N ), 1 ))
182
+ b .codspeedTimePerRoundNs = append (b .codspeedTimePerRoundNs , timeSinceStart )
181
183
}
182
184
}
183
185
0 commit comments