From charlesreid1

Revision as of 05:25, 19 March 2017 by Admin (talk | contribs)

Methods

There are various methods for profiling Java code. Some are covered below.


Java Mission Control

Not nearly as useful, since you don't get a method-level breakdown of how much time was spent in various places in the code. Lots and lots of superfluous information, though.

Compiling

Nothing special is required when you compile your code if you are going to profile it with Java Mission Control.

$ javac NQueens.java

Running

You can specify that Java should create an output file for Java Mission Control by using flags:

$ java -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -Dscijava.log.level=error  \
-XX:StartFlightRecording=name=MyRecording,duration=999s,filename=//tmp/my_flight_recording.jfr,settings=profile NQueens

When that's finished, you can run Java Mission Control, which has a GUI interface and can be used to open the /tmp/my_flight_recording.jfr file:

$ jmc

JMC.png

For the recursive backtracking method, this did not reveal anything about where the real time was being spent.

References

List of Java profiling tools: http://imagej.net/Profiling_Java_Code