| 96 | } |
| 97 | |
| 98 | func 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 | |
| 134 | func BenchmarkRedisSetGetBytes(b *testing.B) { |
| 135 | ctx := context.Background() |