(b *testing.B)
| 47 | } |
| 48 | |
| 49 | func 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 | |
| 73 | func BenchmarkRedisGetNil(b *testing.B) { |
| 74 | ctx := context.Background() |