MCPcopy
hub / github.com/redis/go-redis / BenchmarkWantConnQueue_Enqueue

Function BenchmarkWantConnQueue_Enqueue

internal/pool/want_conn_test.go:377–396  ·  view source on GitHub ↗

Benchmark tests

(b *testing.B)

Source from the content-addressed store, hash-verified

375
376// Benchmark tests
377func BenchmarkWantConnQueue_Enqueue(b *testing.B) {
378 q := newWantConnQueue()
379
380 // Pre-allocate a pool of wantConn to reuse
381 const poolSize = 1000
382 wantConnPool := make([]*wantConn, poolSize)
383 for i := 0; i < poolSize; i++ {
384 wantConnPool[i] = &wantConn{
385 ctx: context.Background(),
386 result: make(chan wantConnResult, 1),
387 }
388 }
389
390 b.ResetTimer()
391
392 for i := 0; i < b.N; i++ {
393 w := wantConnPool[i%poolSize]
394 q.enqueue(w)
395 }
396}
397
398func BenchmarkWantConnQueue_Dequeue(b *testing.B) {
399 q := newWantConnQueue()

Callers

nothing calls this directly

Calls 2

newWantConnQueueFunction · 0.85
enqueueMethod · 0.80

Tested by

no test coverage detected