spatial-db/basic_functionality_test.go
2023-10-28 21:40:29 -07:00

35 lines
625 B
Go

package main
import (
"math/rand"
"testing"
"time"
"git.nicholasnovak.io/nnovak/spatial-db/storage"
"git.nicholasnovak.io/nnovak/spatial-db/world"
)
func BenchmarkInsertSomePoints(b *testing.B) {
var server storage.SimpleServer
points := make([]world.BlockPos, b.N)
r := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := 0; i < b.N; i++ {
points[i] = world.BlockPos{
X: int(r.NormFloat64()),
Y: uint(r.NormFloat64()),
Z: int(r.NormFloat64()),
}
}
b.ResetTimer()
for _, point := range points {
if err := server.ChangeBlock(point, world.Generic); err != nil {
b.Error(err)
}
}
}