From charlesreid1

(Created page with "=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 breakd...")
 
Line 21: Line 21:


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


For the recursive backtracking method, this did not reveal anything about where the real time was being spent.  
When that's finished, you can run Java Mission Control, which has a GUI interface and can be used to open the <code>/tmp/my_flight_recording.jfr</code> file:


<pre>
$ jmc
</pre>
[[Image:JMC.png|500px]]
For the recursive backtracking method, this did not reveal anything about where the real time was being spent.


=References=
=References=


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

Revision as of 05:22, 19 March 2017

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