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

Function BenchmarkRedisSetString

bench_test.go:98–132  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

96}
97
98func BenchmarkRedisSetString(b *testing.B) {
99 benchmarks := []setStringBenchmark{
100 {10, 64},
101 {10, 1024},
102 {10, 64 * 1024},
103 {10, 1024 * 1024},
104 {10, 10 * 1024 * 1024},
105
106 {100, 64},
107 {100, 1024},
108 {100, 64 * 1024},
109 {100, 1024 * 1024},
110 {100, 10 * 1024 * 1024},
111 }
112 for _, bm := range benchmarks {
113 b.Run(bm.String(), func(b *testing.B) {
114 ctx := context.Background()
115 client := benchmarkRedisClient(ctx, bm.poolSize)
116 defer client.Close()
117
118 value := strings.Repeat("1", bm.valueSize)
119
120 b.ResetTimer()
121
122 b.RunParallel(func(pb *testing.PB) {
123 for pb.Next() {
124 err := client.Set(ctx, "key", value, 0).Err()
125 if err != nil {
126 b.Fatal(err)
127 }
128 }
129 })
130 })
131 }
132}
133
134func BenchmarkRedisSetGetBytes(b *testing.B) {
135 ctx := context.Background()

Callers

nothing calls this directly

Calls 7

benchmarkRedisClientFunction · 0.85
StringMethod · 0.65
CloseMethod · 0.65
NextMethod · 0.65
ErrMethod · 0.65
SetMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected