mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-13 11:41:52 +01:00
Add PaletteGetBenchmark
This commit is contained in:
parent
4c31d73bbf
commit
375722be3b
@ -2,6 +2,7 @@ package net.minestom.jmh.palette;
|
||||
|
||||
import net.minestom.server.instance.palette.Palette;
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.infra.Blackhole;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -11,7 +12,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
public class PaletteBenchmark {
|
||||
public class PaletteGetBenchmark {
|
||||
|
||||
@Param({"4", "8", "16"})
|
||||
public int dimension;
|
||||
@ -21,10 +22,7 @@ public class PaletteBenchmark {
|
||||
@Setup
|
||||
public void setup() {
|
||||
palette = Palette.newPalette(dimension, 15, 4, 1);
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void loop() {
|
||||
int value = 0;
|
||||
final int dimension = palette.dimension();
|
||||
for (int y = 0; y < dimension; y++) {
|
||||
@ -35,4 +33,16 @@ public class PaletteBenchmark {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void read(Blackhole blackHole) {
|
||||
final int dimension = palette.dimension();
|
||||
for (int y = 0; y < dimension; y++) {
|
||||
for (int x = 0; x < dimension; x++) {
|
||||
for (int z = 0; z < dimension; z++) {
|
||||
blackHole.consume(palette.get(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
public class PaletteFillBenchmark {
|
||||
public class PaletteSetBenchmark {
|
||||
|
||||
@Param({"4", "8", "16"})
|
||||
public int dimension;
|
||||
@ -24,7 +24,20 @@ public class PaletteFillBenchmark {
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void loop() {
|
||||
public void incrWrite() {
|
||||
int value = 0;
|
||||
final int dimension = palette.dimension();
|
||||
for (int y = 0; y < dimension; y++) {
|
||||
for (int x = 0; x < dimension; x++) {
|
||||
for (int z = 0; z < dimension; z++) {
|
||||
palette.set(x, y, z, value++);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void randomWrite() {
|
||||
final int dimension = palette.dimension();
|
||||
for (int y = 0; y < dimension; y++) {
|
||||
for (int x = 0; x < dimension; x++) {
|
Loading…
Reference in New Issue
Block a user