Skip to content

Commit 06b5b97

Browse files
committed
fix: resolve benchmars too long issue
1 parent c9eabca commit 06b5b97

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

cmd/webhooked/test_webhooked_config.yaml

Whitespace-only changes.

semaphore/semaphore_test.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ func BenchmarkSemaphore_Execute(b *testing.B) {
289289

290290
b.ResetTimer()
291291
for i := 0; i < b.N; i++ {
292-
s.Execute(context.Background(), i) // nolint:errcheck
292+
err := s.Execute(context.Background(), i)
293+
require.NoError(b, err)
293294
}
294295
}
295296

@@ -308,7 +309,8 @@ func BenchmarkSemaphore_Execute_WithWorkers(b *testing.B) {
308309

309310
b.ResetTimer()
310311
for i := 0; i < b.N; i++ {
311-
s.Execute(context.Background(), i) // nolint:errcheck
312+
err := s.Execute(context.Background(), i)
313+
require.NoError(b, err)
312314
}
313315
}
314316

@@ -328,7 +330,8 @@ func BenchmarkSemaphore_Execute_Concurrent(b *testing.B) {
328330
b.RunParallel(func(pb *testing.PB) {
329331
i := 0
330332
for pb.Next() {
331-
s.Execute(context.Background(), i) // nolint:errcheck
333+
err := s.Execute(context.Background(), i)
334+
require.NoError(b, err)
332335
i++
333336
}
334337
})
@@ -355,7 +358,8 @@ func BenchmarkSemaphore_WithRetries(b *testing.B) {
355358

356359
b.ResetTimer()
357360
for i := 0; i < b.N; i++ {
358-
s.Execute(context.Background(), i) // nolint:errcheck
361+
err := s.Execute(context.Background(), i)
362+
require.NoError(b, err)
359363
}
360364
}
361365

@@ -373,7 +377,8 @@ func BenchmarkSemaphore_SetCapacity(b *testing.B) {
373377
b.ResetTimer()
374378
for i := 0; i < b.N; i++ {
375379
newCapacity := int32(100 + (i % 100))
376-
s.SetCapacity(newCapacity) // nolint:errcheck
380+
err := s.SetCapacity(newCapacity)
381+
require.NoError(b, err)
377382
}
378383
}
379384

@@ -387,13 +392,14 @@ func BenchmarkSemaphore_ProcessingSpeed(b *testing.B) {
387392
},
388393
}
389394
s := semaphore.New(exec,
390-
semaphore.WithCapacity(1000),
395+
semaphore.WithCapacity(int32(b.N)),
391396
semaphore.WithMaxWorkers(10))
392397
s.StartConsumers()
393398

394399
// Fill the queue
395400
for i := 0; i < b.N; i++ {
396-
s.Execute(context.Background(), i) // nolint:errcheck
401+
err := s.Execute(context.Background(), i)
402+
require.NoError(b, err)
397403
}
398404

399405
// Wait for all to be processed

0 commit comments

Comments
 (0)