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

Function BenchmarkSetGoroutines

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

Source from the content-addressed store, hash-verified

47}
48
49func BenchmarkSetGoroutines(b *testing.B) {
50 ctx := context.Background()
51 rdb := benchmarkRedisClient(ctx, 10)
52 defer rdb.Close()
53
54 for i := 0; i < b.N; i++ {
55 var wg sync.WaitGroup
56
57 for i := 0; i < 1000; i++ {
58 wg.Add(1)
59 go func() {
60 defer wg.Done()
61
62 err := rdb.Set(ctx, "hello", "world", 0).Err()
63 if err != nil {
64 panic(err)
65 }
66 }()
67 }
68
69 wg.Wait()
70 }
71}
72
73func BenchmarkRedisGetNil(b *testing.B) {
74 ctx := context.Background()

Callers

nothing calls this directly

Calls 6

benchmarkRedisClientFunction · 0.85
WaitMethod · 0.80
CloseMethod · 0.65
AddMethod · 0.65
ErrMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected