2023-12-10 21:46:15 -08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"testing"
|
|
|
|
|
2023-12-13 23:48:53 -08:00
|
|
|
"github.com/NickyBoy89/spatial-db/storage"
|
|
|
|
"github.com/NickyBoy89/spatial-db/world"
|
2023-12-10 21:46:15 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
func readBlockTemplate(
|
|
|
|
storageServer storage.StorageServer,
|
|
|
|
b *testing.B,
|
|
|
|
pointSpread int,
|
|
|
|
) {
|
|
|
|
b.ResetTimer()
|
|
|
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
pos := world.RandomBlockPosWithRange(float64(pointSpread))
|
|
|
|
if _, err := storageServer.ReadBlockAt(pos); err != nil {
|
2023-12-13 23:33:10 -08:00
|
|
|
if errors.Is(err, storage.ChunkNotFoundError) {
|
2023-12-10 21:46:15 -08:00
|
|
|
continue
|
|
|
|
} else {
|
|
|
|
b.Error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|