From 93c7564c43dfe1406a53a90d4c624304b157ed43 Mon Sep 17 00:00:00 2001 From: Nicholas Novak <34256932+NickyBoy89@users.noreply.github.com> Date: Tue, 5 Dec 2023 14:42:57 -0800 Subject: [PATCH] change: Updated benchmarks to only use reads --- scaling_test.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scaling_test.go b/scaling_test.go index f340b75..519ed9b 100644 --- a/scaling_test.go +++ b/scaling_test.go @@ -1,6 +1,7 @@ package main import ( + "errors" "testing" "git.nicholasnovak.io/nnovak/spatial-db/storage" @@ -13,14 +14,17 @@ func init() { server.SetStorageRoot("skygrid-save") } -// insertPointTemplate inserts a configurable variety of points into the server -func insertPointTemplate(testDir string, b *testing.B, pointSpread int) { +func readBlockTemplate(rootDir string, b *testing.B, pointSpread int) { b.ResetTimer() for i := 0; i < b.N; i++ { pos := world.RandomBlockPosWithRange(float64(pointSpread)) - if err := server.ChangeBlock(pos, world.Generic); err != nil { - b.Error(err) + if _, err := server.ReadBlockAt(pos); err != nil { + if errors.Is(err, storage.ChunkNotFoundError) { + continue + } else { + b.Error(err) + } } } } @@ -38,10 +42,10 @@ func fetchChunkTemplate(testDir string, b *testing.B) { // Insert blocks -func BenchmarkInsertClusteredPoints(b *testing.B) { - insertPointTemplate("imperial-test", b, 128) +func BenchmarkReadClusteredPoints(b *testing.B) { + readBlockTemplate("skygrid-test", b, 128) } -func BenchmarkInsertSparserPoints(b *testing.B) { - insertPointTemplate("imperial-test", b, 2048) +func BenchmarkReadSparserPoints(b *testing.B) { + readBlockTemplate("skygrid-test", b, 2048) }