mirror of https://github.com/Minestom/Minestom.git
Palette benchmarks
This commit is contained in:
parent
7fb0ac8fd0
commit
d4eaeffb30
|
@ -0,0 +1,38 @@
|
||||||
|
package net.minestom.jmh.palette;
|
||||||
|
|
||||||
|
import net.minestom.server.instance.palette.Palette;
|
||||||
|
import org.openjdk.jmh.annotations.*;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@Warmup(iterations = 5, time = 1500, timeUnit = TimeUnit.MILLISECONDS)
|
||||||
|
@Measurement(iterations = 10, time = 1500, timeUnit = TimeUnit.MILLISECONDS)
|
||||||
|
@Fork(3)
|
||||||
|
@BenchmarkMode(Mode.AverageTime)
|
||||||
|
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||||
|
@State(Scope.Benchmark)
|
||||||
|
public class PaletteBenchmark {
|
||||||
|
|
||||||
|
@Param({"4", "8", "16"})
|
||||||
|
public int dimension;
|
||||||
|
|
||||||
|
private Palette palette;
|
||||||
|
|
||||||
|
@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++) {
|
||||||
|
for (int x = 0; x < dimension; x++) {
|
||||||
|
for (int z = 0; z < dimension; z++) {
|
||||||
|
palette.set(x, y, z, value++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package net.minestom.jmh.palette;
|
||||||
|
|
||||||
|
import net.minestom.server.instance.palette.Palette;
|
||||||
|
import org.openjdk.jmh.annotations.*;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@Warmup(iterations = 5, time = 1500, timeUnit = TimeUnit.MILLISECONDS)
|
||||||
|
@Measurement(iterations = 10, time = 1500, timeUnit = TimeUnit.MILLISECONDS)
|
||||||
|
@Fork(3)
|
||||||
|
@BenchmarkMode(Mode.AverageTime)
|
||||||
|
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||||
|
@State(Scope.Benchmark)
|
||||||
|
public class PaletteFillBenchmark {
|
||||||
|
|
||||||
|
@Param({"4", "8", "16"})
|
||||||
|
public int dimension;
|
||||||
|
|
||||||
|
private Palette palette;
|
||||||
|
|
||||||
|
@Setup
|
||||||
|
public void setup() {
|
||||||
|
palette = Palette.newPalette(dimension, 15, 4, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
public void loop() {
|
||||||
|
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, 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
public void fill() {
|
||||||
|
palette.fill(5);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue