| 132 | } |
| 133 | |
| 134 | func BenchmarkRedisSetGetBytes(b *testing.B) { |
| 135 | ctx := context.Background() |
| 136 | client := benchmarkRedisClient(ctx, 10) |
| 137 | defer client.Close() |
| 138 | |
| 139 | value := bytes.Repeat([]byte{'1'}, 10000) |
| 140 | |
| 141 | b.ResetTimer() |
| 142 | |
| 143 | b.RunParallel(func(pb *testing.PB) { |
| 144 | for pb.Next() { |
| 145 | if err := client.Set(ctx, "key", value, 0).Err(); err != nil { |
| 146 | b.Fatal(err) |
| 147 | } |
| 148 | |
| 149 | got, err := client.Get(ctx, "key").Bytes() |
| 150 | if err != nil { |
| 151 | b.Fatal(err) |
| 152 | } |
| 153 | if !bytes.Equal(got, value) { |
| 154 | b.Fatalf("got != value") |
| 155 | } |
| 156 | } |
| 157 | }) |
| 158 | } |
| 159 | |
| 160 | // benchmarkRedisGet runs the classic Get-into-string path so it can be |
| 161 | // compared head-to-head with benchmarkRedisGetToBuffer for the same value |