use fixed seed for PaletteGetPresentBenchmark and add readAllPresentAlt benchmark

This commit is contained in:
Eoghanmc22 2022-01-07 19:34:40 -05:00 committed by TheMode
parent 3eb0bc28c0
commit 8de5ba1149
1 changed files with 11 additions and 2 deletions

View File

@ -4,7 +4,7 @@ import net.minestom.server.instance.palette.Palette;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import java.util.concurrent.ThreadLocalRandom;
import java.util.Random;
import java.util.concurrent.TimeUnit;
@Warmup(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
@ -23,7 +23,7 @@ public class PaletteGetPresentBenchmark {
@Setup
public void setup() {
palette = Palette.blocks();
var random = ThreadLocalRandom.current();
var random = new Random(18932365);
final int dimension = palette.dimension();
for (int y = 0; y < dimension; y++)
for (int z = 0; z < dimension; z++)
@ -41,4 +41,13 @@ public class PaletteGetPresentBenchmark {
public void readAllPresent(Blackhole blackHole) {
palette.getAllPresent((x, y, z, value) -> blackHole.consume(value));
}
@Benchmark
public void readAllPresentAlt(Blackhole blackHole) {
palette.getAll((x, y, z, value) -> {
if (value != 0) {
blackHole.consume(value);
}
});
}
}