Skip to content

Commit

Permalink
Add linestring benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
tidwall committed Nov 16, 2024
1 parent 69a36ed commit d445566
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion cmd/tile38-benchmark/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit d445566

Please sign in to comment.