This section provides a tutorial example on how to run benchmark tests in interpreted-only mode using the '-Xint' JVM option.
Another interesting performance test is see how fast the test code can run
in interpreted-only mode. This can be archived by disabling the JIT compilation in the JVM
so that all bytecodes will be executed by the interpreter.
To force the JVM to stay in interpreted-only mode, you need to use the "-Xint" option
as shown in the following test:
C:\herong\jvm>java -Xint -XX:+PrintGC -XX:+PrintCompilation
-Xms100m -Xmx100m
BenchmarkRunner BenchmarkLoopTest emptyLoop 10000 3 3
Are you ready?
y
Waking up the JIT compiler...
Run: 1, Time: 6426, Test returns: 3
Run: 2, Time: 3632, Test returns: 3
Run: 3, Time: 3352, Test returns: 3
...
Run: 1065, Time: 3352, Test returns: 3
Run: 1066, Time: 3073, Test returns: 3
Run: 1067, Time: 3073, Test returns: 3
Run: 1068, Time: 2235, Test returns: 3
Run: 1069, Time: 2514, Test returns: 3
...
Run: 9995, Time: 2514, Test returns: 3
Run: 9996, Time: 2514, Test returns: 3
Run: 9997, Time: 2515, Test returns: 3
Run: 9998, Time: 2515, Test returns: 3
Run: 9999, Time: 2235, Test returns: 3
Run: 10000, Time: 2235, Test returns: 3
...
Conclusions based on the test result:
"-Xint" option is working. No JIT compilations happened.
The execution time in interpreted-only mode is about 2514 nanoseconds for
the empty loop of 3 iterations.
The execution time in native code produced by the JIT compilation is about 1956 nanoseconds
for the empty loop of 3 iterations based on previous tests.