From 5a3ef0fe69952ccfb3e5937ef3a78f4cf61f2f94 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Wed, 22 Jan 2025 05:49:17 +1000 Subject: [PATCH] Performance benching --- .../me/cortex/voxy/client/core/VoxelCore.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/cortex/voxy/client/core/VoxelCore.java b/src/main/java/me/cortex/voxy/client/core/VoxelCore.java index 998b111d..cced8d00 100644 --- a/src/main/java/me/cortex/voxy/client/core/VoxelCore.java +++ b/src/main/java/me/cortex/voxy/client/core/VoxelCore.java @@ -89,8 +89,9 @@ public class VoxelCore { //this.verifyTopNodeChildren(0,0,0); //this.testMeshingPerformance(); - } + //this.testDbPerformance(); + } public void enqueueIngest(WorldChunk worldChunk) { this.world.ingestService.enqueueIngest(worldChunk); @@ -356,4 +357,25 @@ public class VoxelCore { } + private void testDbPerformance() { + Random r = new Random(123456); + r.nextLong(); + long start = System.currentTimeMillis(); + int c = 0; + for (int i = 0; i < 500_000; i++) { + if (i == 20_000) { + c = 0; + start = System.currentTimeMillis(); + } + c++; + int x = (r.nextInt(256*2+2)-256)>>1;//-32 + int z = (r.nextInt(256*2+2)-256)>>1;//-32 + int y = 0; + int lvl = 0;//r.nextInt(5); + this.world.acquire(WorldEngine.getWorldSectionId(lvl, x>>lvl, y>>lvl, z>>lvl)).release(); + } + long delta = System.currentTimeMillis() - start; + System.out.println("Total "+delta+"ms " + ((double)delta/c) + "ms average" ); + } + }