mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-09 17:26:07 +00:00
Implement NoiseFunction2 cache
This commit is contained in:
@@ -9,13 +9,32 @@ public class NoiseTest {
|
||||
@Test
|
||||
public void noise() {
|
||||
NoiseFunction2 noiseFunction = new NoiseFunction2(12345, new NoiseBuilder());
|
||||
|
||||
System.out.println("Cache:");
|
||||
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)));
|
||||
for(int j = 0; j < 20000; j++) {
|
||||
for(int x = 0; x < 4; x++) {
|
||||
for(int y = 0; y < 64; y++) {
|
||||
for(int z = 0; z < 4; z++) {
|
||||
noiseFunction.eval(Arrays.asList(get(j * 16 + (x * 4)), get(i * 16 + (z * 4))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
double n = System.nanoTime() - l;
|
||||
System.out.println(n / 1000000 + "ms");
|
||||
}
|
||||
System.out.println("No Cache:");
|
||||
for(int i = 0; i < 10; i++) {
|
||||
long l = System.nanoTime();
|
||||
for(int j = 0; j < 20000; j++) {
|
||||
for(int x = 0; x < 4; x++) {
|
||||
for(int y = 0; y < 64; y++) {
|
||||
for(int z = 0; z < 4; z++) {
|
||||
noiseFunction.evalNoCache(Arrays.asList(get(j * 16 + (x * 4)), get(i * 16 + (z * 4))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
double n = System.nanoTime() - l;
|
||||
System.out.println(n / 1000000 + "ms");
|
||||
|
||||
Reference in New Issue
Block a user