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

Function BenchmarkPoolGetPut

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

Source from the content-addressed store, hash-verified

19}
20
21func BenchmarkPoolGetPut(b *testing.B) {
22 ctx := context.Background()
23 benchmarks := []poolGetPutBenchmark{
24 {1},
25 {2},
26 {8},
27 {32},
28 {64},
29 {128},
30 }
31 for _, bm := range benchmarks {
32 b.Run(bm.String(), func(b *testing.B) {
33 connPool := pool.NewConnPool(&pool.Options{
34 Dialer: dummyDialer,
35 PoolSize: int32(bm.poolSize),
36 MaxConcurrentDials: bm.poolSize,
37 PoolTimeout: time.Second,
38 DialTimeout: 1 * time.Second,
39 ConnMaxIdleTime: time.Hour,
40 })
41
42 b.ResetTimer()
43
44 b.RunParallel(func(pb *testing.PB) {
45 for pb.Next() {
46 cn, err := connPool.Get(ctx)
47 if err != nil {
48 b.Fatal(err)
49 }
50 connPool.Put(ctx, cn)
51 }
52 })
53 })
54 }
55}
56
57type poolGetRemoveBenchmark struct {
58 poolSize int

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected