@@ -182,11 +182,15 @@ func (b *B) StopTimer() {
182
182
// If we hit B.Loop with the timer stopped, fail.
183
183
// b.loop.i |= loopPoisonTimer
184
184
185
-
186
185
// Accumulate timestamps for batch submission instead of immediate hook call
187
186
b .codspeed .accumulatedStartTimestamps = append (b .codspeed .accumulatedStartTimestamps , b .codspeed .startTimestamp )
188
187
b .codspeed .accumulatedEndTimestamps = append (b .codspeed .accumulatedEndTimestamps , endTimestamp )
189
188
189
+ // Debug log every 10000 accumulated timestamps to detect potential memory issues
190
+ if len (b .codspeed .accumulatedStartTimestamps )% 10000 == 0 && len (b .codspeed .accumulatedStartTimestamps ) > 0 {
191
+ fmt .Printf ("DEBUG: Accumulated %d timestamp pairs for benchmark %s\n " , len (b .codspeed .accumulatedStartTimestamps ), b .name )
192
+ }
193
+
190
194
// For b.N loops: This will be called in runN which sets b.N to the number of iterations.
191
195
// For b.Loop() loops: loopSlowPath sets b.N to 0 to prevent b.N loops within b.Loop. However, since
192
196
// we're starting/stopping the timer for each iteration in the b.Loop() loop, we can use 1 as
@@ -225,7 +229,11 @@ func (b *B) ResetTimer() {
225
229
}
226
230
227
231
func (b * B ) submitAccumulatedTimestamps () {
228
- for i := 0 ; i < len (b .codspeed .accumulatedStartTimestamps ); i ++ {
232
+ numTimestamps := len (b .codspeed .accumulatedStartTimestamps )
233
+ if numTimestamps > 0 {
234
+ fmt .Printf ("DEBUG: Submitting %d accumulated timestamp pairs for benchmark %s\n " , numTimestamps , b .name )
235
+ }
236
+ for i := 0 ; i < numTimestamps ; i ++ {
229
237
b .codspeed .instrument_hooks .AddBenchmarkTimestamps (
230
238
b .codspeed .accumulatedStartTimestamps [i ],
231
239
b .codspeed .accumulatedEndTimestamps [i ],
@@ -598,7 +606,7 @@ func (b *B) loopSlowPath() bool {
598
606
// whereas b.N-based benchmarks must run the benchmark function (and any
599
607
// associated setup and cleanup) several times.
600
608
func (b * B ) Loop () bool {
601
- b .StopTimer ()
609
+ // b.StopTimer()
602
610
// This is written such that the fast path is as fast as possible and can be
603
611
// inlined.
604
612
//
@@ -613,7 +621,7 @@ func (b *B) Loop() bool {
613
621
// path can do consistency checks and fail.
614
622
if b .loop .i < b .loop .n {
615
623
b .loop .i ++
616
- b .StartTimer ()
624
+ // b.StartTimer()
617
625
return true
618
626
}
619
627
return b .loopSlowPath ()
0 commit comments