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

Function BenchmarkPoolGetPut

pool_pubsub_bench_test.go:65–97  ·  view source on GitHub ↗

============================================================================= POOL BENCHMARKS ============================================================================= BenchmarkPoolGetPut benchmarks the core pool Get/Put operations

(b *testing.B)

Source from the content-addressed store, hash-verified

63
64// BenchmarkPoolGetPut benchmarks the core pool Get/Put operations
65func BenchmarkPoolGetPut(b *testing.B) {
66 ctx := context.Background()
67
68 poolSizes := []int{1, 2, 4, 8, 16, 32, 64, 128}
69
70 for _, poolSize := range poolSizes {
71 b.Run(fmt.Sprintf("PoolSize_%d", poolSize), func(b *testing.B) {
72 connPool := pool.NewConnPool(&pool.Options{
73 Dialer: dummyDialer,
74 PoolSize: int32(poolSize),
75 MaxConcurrentDials: poolSize,
76 PoolTimeout: time.Second,
77 DialTimeout: time.Second,
78 ConnMaxIdleTime: time.Hour,
79 MinIdleConns: int32(0), // Start with no idle connections
80 })
81 defer connPool.Close()
82
83 b.ResetTimer()
84 b.ReportAllocs()
85
86 b.RunParallel(func(pb *testing.PB) {
87 for pb.Next() {
88 cn, err := connPool.Get(ctx)
89 if err != nil {
90 b.Fatal(err)
91 }
92 connPool.Put(ctx, cn)
93 }
94 })
95 })
96 }
97}
98
99// BenchmarkPoolGetPutWithMinIdle benchmarks pool operations with MinIdleConns
100func BenchmarkPoolGetPutWithMinIdle(b *testing.B) {

Callers

nothing calls this directly

Calls 6

CloseMethod · 0.95
GetMethod · 0.95
PutMethod · 0.95
NewConnPoolFunction · 0.92
NextMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected