From d445566c064a8f0c22ee6a19c0a8666928b5b6dd Mon Sep 17 00:00:00 2001 From: tidwall Date: Sat, 16 Nov 2024 08:19:41 -0700 Subject: [PATCH] Add linestring benchmark --- cmd/tile38-benchmark/main.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cmd/tile38-benchmark/main.go b/cmd/tile38-benchmark/main.go index f0f0b931..eec903ba 100644 --- a/cmd/tile38-benchmark/main.go +++ b/cmd/tile38-benchmark/main.go @@ -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 { redbench.Bench("SET", addr, opts, prepFn, func(buf []byte) []byte { @@ -299,6 +299,22 @@ func main() { ) } 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": redbench.Bench("SET (string)", addr, opts, prepFn, func(buf []byte) []byte {