Changed test parameters, added large sized test.

This commit is contained in:
Harrison Deng 2020-04-29 21:26:22 -05:00
parent c963ad140f
commit 21e8e52b9c

View File

@ -27,8 +27,8 @@ import ca.recrown.islandsurvivalcraft.world.IslandWorldMapper;
public class UniBiomeIslandGeneratorTest { public class UniBiomeIslandGeneratorTest {
private final int SEED = 249398015; private final int SEED = 249398015;
private final DummyWorld dummyWorld = new DummyWorld(); private final DummyWorld dummyWorld = new DummyWorld();
private final Cache<Point2, Double> blockValueCache = new Cache<>(4096); private final Cache<Point2, Double> blockValueCache = new Cache<>(524288);
private final Cache<Point2, Biome[]> biomeCache = new Cache<>(4096); private final Cache<Point2, Biome[]> biomeCache = new Cache<>(524288);
private final Cache<Point2, Boolean> chunkExistenceCache = new Cache<>(16384); private final Cache<Point2, Boolean> chunkExistenceCache = new Cache<>(16384);
private class BiomeGenTask implements Runnable { private class BiomeGenTask implements Runnable {
@ -136,4 +136,34 @@ public class UniBiomeIslandGeneratorTest {
} }
} }
} }
@Test
@Timeout(value = 1, unit = TimeUnit.MINUTES)
public void testBiomeGenerationMultithread6000ChunksScatteredColumns() {
int chunksToDoEach = 1000;
Runnable g1 = new BiomeGenTask(chunksToDoEach, 0);
Runnable g2 = new BiomeGenTask(chunksToDoEach, 2);
Runnable g3 = new BiomeGenTask(chunksToDoEach, 4);
Runnable g4 = new BiomeGenTask(chunksToDoEach, 6);
Runnable g5 = new BiomeGenTask(chunksToDoEach, 8);
Runnable g6 = new BiomeGenTask(chunksToDoEach, 10);
ExecutorService ex = Executors.newFixedThreadPool(6);
LinkedList<Future<?>> tasks = new LinkedList<>();
tasks.add(ex.submit(g1));
tasks.add(ex.submit(g2));
tasks.add(ex.submit(g3));
tasks.add(ex.submit(g4));
tasks.add(ex.submit(g5));
tasks.add(ex.submit(g6));
while (!tasks.isEmpty()) {
try {
tasks.pop().get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
assertFalse(false, e.getCause().getMessage());
}
}
}
} }