-
Notifications
You must be signed in to change notification settings - Fork 3
/
bench_multi_map.go
33 lines (25 loc) · 741 Bytes
/
bench_multi_map.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"math/rand"
"time"
"github.com/tidwall/redbench"
)
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
func init() {
rand.Seed(time.Now().UnixNano())
}
func randomString(length int) string {
b := make([]rune, length)
for i := range b {
b[i] = letterRunes[rand.Intn(len(letterRunes))]
}
return string(b)
}
func main() {
redbench.Bench("MULTIMAP.INSERT", "127.0.0.1:6379", nil, nil, func(buf []byte) []byte {
return redbench.AppendCommand(buf, "MULTIMAP.INSERT", "map", randomString(5), randomString(10))
})
redbench.Bench("SET", "127.0.0.1:6379", nil, nil, func(buf []byte) []byte {
return redbench.AppendCommand(buf, "SET", randomString(5), randomString(10))
})
}