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

Function BenchmarkPoolGetRemove

internal/pool/bench_test.go:65–100  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

63}
64
65func BenchmarkPoolGetRemove(b *testing.B) {
66 ctx := context.Background()
67 benchmarks := []poolGetRemoveBenchmark{
68 {1},
69 {2},
70 {8},
71 {32},
72 {64},
73 {128},
74 }
75
76 for _, bm := range benchmarks {
77 b.Run(bm.String(), func(b *testing.B) {
78 connPool := pool.NewConnPool(&pool.Options{
79 Dialer: dummyDialer,
80 PoolSize: int32(bm.poolSize),
81 MaxConcurrentDials: bm.poolSize,
82 PoolTimeout: time.Second,
83 DialTimeout: 1 * time.Second,
84 ConnMaxIdleTime: time.Hour,
85 })
86
87 b.ResetTimer()
88 rmvErr := errors.New("Bench test remove")
89 b.RunParallel(func(pb *testing.PB) {
90 for pb.Next() {
91 cn, err := connPool.Get(ctx)
92 if err != nil {
93 b.Fatal(err)
94 }
95 connPool.Remove(ctx, cn, rmvErr)
96 }
97 })
98 })
99 }
100}

Callers

nothing calls this directly

Calls 6

GetMethod · 0.95
RemoveMethod · 0.95
NewConnPoolFunction · 0.92
StringMethod · 0.65
NextMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected