Use setAll for PaletteGetBenchmark

This commit is contained in:
themode 2022-01-06 01:51:46 +01:00 committed by TheMode
parent 4258e14c5f
commit 83621e2ece

View File

@ -5,6 +5,7 @@ import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole; import org.openjdk.jmh.infra.Blackhole;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@Warmup(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 10, time = 1000, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 10, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
@ -22,16 +23,8 @@ public class PaletteGetBenchmark {
@Setup @Setup
public void setup() { public void setup() {
palette = Palette.newPalette(dimension, 15, 4, 1); palette = Palette.newPalette(dimension, 15, 4, 1);
AtomicInteger value = new AtomicInteger();
int value = 0; palette.setAll((x, y, z) -> value.getAndIncrement());
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++);
}
}
}
} }
@Benchmark @Benchmark