mirror of
https://github.com/Minestom/Minestom.git
synced 2025-03-02 11:21:15 +01:00
use fixed seed for PaletteGetPresentBenchmark and add readAllPresentAlt benchmark
This commit is contained in:
parent
3eb0bc28c0
commit
8de5ba1149
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user