Skip to content

Commit 482651b

Browse files
authored
[chore] Fix benchmark (#14212)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description `b.Loop()` should not be used after it has returned false. This changes the code to run offer a bunch of times and then consume a bunch of times I believe this is what is making codspeed fail.
1 parent f09e5ef commit 482651b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

exporter/exporterhelper/internal/queue/persistent_queue_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -806,11 +806,12 @@ func BenchmarkPersistentQueue(b *testing.B) {
806806
b.ReportAllocs()
807807

808808
for b.Loop() {
809-
require.NoError(b, ps.Offer(context.Background(), req))
810-
}
811-
812-
for b.Loop() {
813-
require.True(b, consume(ps, func(context.Context, intRequest) error { return nil }))
809+
for range 100 {
810+
require.NoError(b, ps.Offer(context.Background(), req))
811+
}
812+
for range 100 {
813+
require.True(b, consume(ps, func(context.Context, intRequest) error { return nil }))
814+
}
814815
}
815816
require.NoError(b, ext.Shutdown(context.Background()))
816817
}

0 commit comments

Comments
 (0)