Slightly improve performance of NoiseFunction2

This commit is contained in:
dfsek
2020-11-20 23:09:00 -07:00
parent e43d814169
commit c96127fde7
4 changed files with 29 additions and 28 deletions

View File

@@ -0,0 +1,28 @@
import com.dfsek.terra.generation.config.NoiseBuilder;
import com.dfsek.terra.math.NoiseFunction2;
import org.junit.jupiter.api.Test;
import parsii.eval.Expression;
import java.util.Arrays;
public class NoiseTest {
@Test
public void noise() {
NoiseFunction2 noiseFunction = new NoiseFunction2(12345, new NoiseBuilder());
for(int i = 0; i < 10; i++) {
long l = System.nanoTime();
for(int j = 0; j < 1000000; j++) {
noiseFunction.eval(Arrays.asList(get(j), get(i)));
noiseFunction.eval(Arrays.asList(get(j), get(i)));
noiseFunction.eval(Arrays.asList(get(j), get(i)));
}
double n = System.nanoTime() - l;
System.out.println(n / 1000000 + "ms");
}
}
private Expression get(double val) {
return () -> val;
}
}