Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eager java class loading

Tags:

java

I'm trying to do some benchmarking of JVMs running on various hardware and OS platforms. I've created an algorithm to exercise the parts of the JVM I'm interested in and intend to run this algorithm many times to find a decent average.

When I run the benchmark, I find that the first run is significantly longer than subsequent runs:

132ms
86ms
77ms
89ms
72ms

My suspicion is that classes are loaded lazily, putting a large overhead on the first run. While this is indeed a feature that I assume is unique to each JVM, it's not one I'm interested in at this point.

Is there a standard command line option or property to eagerly load classes? or does anyone have any other theories?

like image 848
Cogsy Avatar asked Mar 01 '09 10:03

Cogsy


1 Answers

Use java -XX:+TraceClassLoading to trace the loading of classes.

Use java -XX:+PrintCompilation to trace when methods are JITed.

like image 123
akuhn Avatar answered Oct 07 '22 09:10

akuhn