Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

-Djava.compiler=NONE didn't disable JIT in Java 5

Status
Not open for further replies.

kknight2046

Programmer
Jul 6, 2006
17
US
The -Djava.compiler=NONE option is supposed to disable JIT. But my experiment showed that -Djava.compiler=NONE took no effect in Java 5.

Here is the program Main.java:

public class Main {
public static void main (String [] args)
{
for (int repeat = 0; repeat < 25; ++ repeat) {
long start = System.nanoTime();
sum (500);
long end = System.nanoTime();

System.out.println (repeat + ": " + (end-start));
}
}

public static int sum (int n)
{
if (n <= 1)
return 1;
else
return n + sum (n - 1);
}
} // End of class

I compiled it: javac -g Main.java
Then I ran it using: java -XX:+PrintCompilation -Xdebug -Xnoagent -Djava.compiler=NONE Main

The results are as below:
0: 161000
1: 162000
2: 66000
3: 66000
4: 66000
5: 66000
6: 108000
7: 91000
8: 69000
9: 69000
10: 178000
11: 69000
12: 69000
13: 68000
14: 68000
15: 68000
16: 68000
17: 69000
18: 68000
19: 161000
20: 68000 1
Main::sum (16 bytes)
21: 68000
22: 70000
23: 69000
24: 68000

Line 20 showed that Hotpot compiled sum(). Since there is
-Djava.compiler=NONE option in the command line. No just-in-time compilation should be performed.

I did the same experiment in Java 6. In Java 6 experiment the -Djava.compiler=NONE turned off the just-in-time compilation.

Any thoughts?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top