I have tried to test Java performance on OpenVMS (Itanium, OS 8.3). I created some sample classes to test performance as below
HEZ[AUN]$type Test.java
import java.util.Date;
public class Test {
public static void main(String args[]) {
Date d1 = new Date();
System.out.println(d1);
for (int k = 0;k < 1;k++) {
for (int i = 0;i < Integer.MAX_VALUE;i++) {
for (int j = 0;j < Integer.MAX_VALUE;j++) {
}
}
}
Date d2 = new Date();
System.out.println(d2.getTime() - d1.getTime());
}
}
HEZ[AUN]$type Test2.java
import java.util.Date;
public class Test2 {
public static void main(String args[]) {
Date d1 = new Date();
System.out.println(d1);
// for (int k = 0;k < 1;k++) {
for (int i = 0;i < Integer.MAX_VALUE;i++) {
for (int j = 0;j < Integer.MAX_VALUE;j++) {
}
}
// }
Date d2 = new Date();
System.out.println(d2.getTime() - d1.getTime());
}
}
I then compiled as follows:
HEZ[AUN]$javac Test.java
HEZ[AUN]$javac Test2.java
HEZ[AUN]$java "Test"
Tue Feb 21 18:04:57 GMT+07:00 2012
3574
HEZ[AUN]$java "Test2"
Tue Feb 21 18:05:03 GMT+07:00 2012
282
From the above, I don't understand why code that has an additional line for loop "for 1 time" is taking more time when compared with code "without for"
Should I modify some OpenVMS system parameter?