Skip to content

Commit feb8790

Browse files
committed
Add some benchmarks
1 parent 763d7d1 commit feb8790

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

pkg/controller/priorityqueue/priorityqueue_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,34 @@ func BenchmarkAddGetDone(b *testing.B) {
300300
}
301301
}
302302

303+
func BenchmarkAddOnly(b *testing.B) {
304+
q := New[int]("")
305+
defer q.ShutDown()
306+
b.ResetTimer()
307+
for n := 0; n < b.N; n++ {
308+
for i := 0; i < 1000; i++ {
309+
q.Add(i)
310+
}
311+
}
312+
}
313+
314+
func BenchmarkAddLockContended(b *testing.B) {
315+
q := New[int]("")
316+
defer q.ShutDown()
317+
go func() {
318+
for range 1000 {
319+
item, _ := q.Get()
320+
q.Done(item)
321+
}
322+
}()
323+
b.ResetTimer()
324+
for n := 0; n < b.N; n++ {
325+
for i := 0; i < 1000; i++ {
326+
q.Add(i)
327+
}
328+
}
329+
}
330+
303331
// TestFuzzPrioriorityQueue validates a set of basic
304332
// invariants that should always be true:
305333
//

0 commit comments

Comments
 (0)