Test bulk all operations

This commit is contained in:
themode 2022-01-04 03:43:12 +01:00 committed by TheMode
parent aac07c8ef1
commit 948073d291
2 changed files with 19 additions and 9 deletions

View File

@ -25,8 +25,8 @@ public class PaletteGetBenchmark {
int value = 0;
final int dimension = palette.dimension();
for (int y = 0; y < dimension; y++) {
for (int x = 0; x < dimension; x++) {
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++);
}
@ -37,12 +37,17 @@ public class PaletteGetBenchmark {
@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 x = 0; x < dimension; x++) {
for (int y = 0; y < dimension; y++) {
for (int z = 0; z < dimension; z++) {
blackHole.consume(palette.get(x, y, z));
}
}
}
}
@Benchmark
public void readAll(Blackhole blackHole) {
palette.getAll((x, y, z, value) -> blackHole.consume(value));
}
}

View File

@ -27,8 +27,8 @@ public class PaletteSetBenchmark {
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 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++);
}
@ -37,10 +37,10 @@ public class PaletteSetBenchmark {
}
@Benchmark
public void randomWrite() {
public void constantWrite() {
final int dimension = palette.dimension();
for (int y = 0; y < dimension; y++) {
for (int x = 0; x < dimension; x++) {
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, 5);
}
@ -48,6 +48,11 @@ public class PaletteSetBenchmark {
}
}
@Benchmark
public void constantWriteAll() {
palette.setAll((x, y, z) -> 5);
}
@Benchmark
public void fill() {
palette.fill(5);