Add linestring benchmark

This commit is contained in:
tidwall 2024-11-16 08:19:41 -07:00
parent 69a36ed176
commit d445566c06
1 changed files with 17 additions and 1 deletions

View File

@ -261,7 +261,7 @@ func main() {
) )
} }
case "SET", "SET-POINT", "SET-RECT", "SET-STRING": case "SET", "SET-POINT", "SET-RECT", "SET-LINE", "SET-STRING":
if redis { if redis {
redbench.Bench("SET", addr, opts, prepFn, redbench.Bench("SET", addr, opts, prepFn,
func(buf []byte) []byte { func(buf []byte) []byte {
@ -299,6 +299,22 @@ func main() {
) )
} }
switch strings.ToUpper(strings.TrimSpace(test)) { switch strings.ToUpper(strings.TrimSpace(test)) {
case "SET", "SET-LINE":
redbench.Bench("SET (line)", addr, opts, prepFn,
func(buf []byte) []byte {
i := atomic.AddInt64(&i, 1)
alat, alon, blat, blon := randRect(10000)
if rand.Int()%2 == 0 {
alat, alon, blat, blon = blat, blon, alat, alon
}
linestring := fmt.Sprintf(`{"type":"LineString","coordinates":[[%f,%f],[%f,%f]]}`, alon, alat, blon, blat)
return redbench.AppendCommand(buf, "SET", "key:bench", "id:"+strconv.FormatInt(i, 10), "OBJECT",
linestring,
)
},
)
}
switch strings.ToUpper(strings.TrimSpace(test)) {
case "SET", "SET-STRING": case "SET", "SET-STRING":
redbench.Bench("SET (string)", addr, opts, prepFn, redbench.Bench("SET (string)", addr, opts, prepFn,
func(buf []byte) []byte { func(buf []byte) []byte {