Hi all,
please have a look at this great piece of code:
public class ArrayTest {
private static int length=196608;
private static int[] pixelArray=new int[length];
private static int[] zbufferArray=new int[length];
private static int color=0;
public static void main(String[] args) {
do {
long start=System.currentTimeMillis();
for (int z=0; z<100; z++) {
clearArray(color);
}
System.out.println(System.currentTimeMillis()-start);
} while (true);
}
private static void clearArray(int color) {
/*
for (int i=0; i<length; i++) {
pixelArray[i]=color;
zbufferArray[i]=-2147483647;
}
*/
for (int i=0; i<length; i++) {
pixelArray[i]=color;
}
for (int i=0; i<length; i++) {
zbufferArray[i]=-2147483647;
}
}
}
When running this on a P4HT@3.2Ghz using the 1.4.2 VM in client mode, each loop takes around 180ms. When using the commented-out array-filling instead (the one that fills both arrays in one loop), i’m at 450ms. But it’s getting even more strange: This test is not a real-world-app (of course not…), but my software renderer is and it’s basically doing the same thing. In that application, i used to use the version with the single loop and it starts fast (like the 180ms version) but it drops to the 450ms performance after some seconds. It doesn’t do this on my AthlonXP 2600+ machine (same OS (XP) and VM). And to complete the wiredness: On this machine, the version with the single loop is faster than the splitted one.
To summerize this:
P4HT/1.4.2/single loop: 450ms
P4HT/1.4.2/two loops: 180ms
XP2600+/1.4.2/single loop: 180ms
XP2600+/1.4.2/two loops: 230ms
I’ve one question: WHY? And why does the P4 starts fast (so obviously, it can run it fast…) when i’m doing this in the actual renderer but drops after some seconds?
BTW: -server mode doesn’t help. It’s a bit faster, but the behaviour is the same.