From 83621e2ece8ac5db9a2bd87472123f8e79a1ff33 Mon Sep 17 00:00:00 2001 From: themode Date: Thu, 6 Jan 2022 01:51:46 +0100 Subject: [PATCH] Use setAll for PaletteGetBenchmark --- .../minestom/jmh/palette/PaletteGetBenchmark.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/jmh-benchmarks/src/jmh/java/net/minestom/jmh/palette/PaletteGetBenchmark.java b/jmh-benchmarks/src/jmh/java/net/minestom/jmh/palette/PaletteGetBenchmark.java index 748945937..27435eb81 100644 --- a/jmh-benchmarks/src/jmh/java/net/minestom/jmh/palette/PaletteGetBenchmark.java +++ b/jmh-benchmarks/src/jmh/java/net/minestom/jmh/palette/PaletteGetBenchmark.java @@ -5,6 +5,7 @@ import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; @Warmup(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 10, time = 1000, timeUnit = TimeUnit.MILLISECONDS) @@ -22,16 +23,8 @@ public class PaletteGetBenchmark { @Setup public void setup() { palette = Palette.newPalette(dimension, 15, 4, 1); - - int value = 0; - final int dimension = palette.dimension(); - for (int x = 0; x < dimension; x++) { - for (int y = 0; y < dimension; y++) { - for (int z = 0; z < dimension; z++) { - palette.set(x, y, z, value++); - } - } - } + AtomicInteger value = new AtomicInteger(); + palette.setAll((x, y, z) -> value.getAndIncrement()); } @Benchmark