mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-09 09:16:34 +00:00
Slightly improve performance of NoiseFunction2
This commit is contained in:
28
src/test/java/NoiseTest.java
Normal file
28
src/test/java/NoiseTest.java
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user