Skip to content

Commit cfdf75b

Browse files
More speed for jmh
1 parent 9a27d56 commit cfdf75b

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

server/src/jmh/java/com/soulfiremc/jmh/PathfindingBenchmark.java

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,32 +68,30 @@ public void setup() {
6868

6969
log.info("Parsing world data...");
7070

71-
var maxY = 0;
71+
log.info("X: {}, Y: {}, Z: {}", data.length, data[0].length, data[0][0].length);
72+
73+
// Find the first safe block at 0 0
74+
var safeY = Integer.MIN_VALUE;
7275
var accessor = new TestBlockAccessorBuilder();
7376
for (var x = 0; x < data.length; x++) {
74-
var xArray = data[x];
75-
for (var y = 0; y < xArray.length; y++) {
76-
var yArray = xArray[y];
77-
for (var z = 0; z < yArray.length; z++) {
78-
accessor.setBlockAt(x, y, z, BlockType.REGISTRY.getByKey(blockDefinitions[yArray[z]]));
79-
maxY = Math.max(maxY, y);
77+
for (var y = 0; y < data[0].length; y++) {
78+
for (var z = 0; z < data[0][0].length; z++) {
79+
var blockType = BlockType.REGISTRY.getByKey(blockDefinitions[data[x][y][z]]);
80+
if (blockType.air()) {
81+
continue;
82+
}
83+
84+
// Insert blocks
85+
accessor.setBlockAt(x, y, z, blockType);
86+
if (x == 0 && z == 0) {
87+
safeY = Math.max(safeY, y + 1);
88+
}
8089
}
8190
}
8291
}
8392

84-
log.info("Calculating world data...");
85-
8693
var builtAccessor = accessor.build();
8794

88-
// Find the first safe block at 0 0
89-
var safeY = 0;
90-
for (var y = maxY; y >= 0; y--) {
91-
if (builtAccessor.getBlockState(0, y, 0).blockType() != BlockType.AIR) {
92-
safeY = y + 1;
93-
break;
94-
}
95-
}
96-
9795
var inventory = ProjectedInventory.forUnitTest(List.of(), TestPathConstraint.INSTANCE);
9896
initialState = NodeState.forInfo(new SFVec3i(0, safeY, 0), inventory);
9997
log.info("Initial state: {}", initialState.blockPosition().formatXYZ());

0 commit comments

Comments
 (0)