[Texas PLT logo]

COMP 402: Production Programming

  Profiling  

Today's Menu:

Profiling

Profiling means recording information about a program as it runs, for example how much time is spent where, how often certain programs are called, how much memory is used, and so on. Profiling is a dynamic analysis technique, as opposed to static analysis (e.g. FindBugs).

Running YourKit on DrJava

Follow the instructions for YourKit in the DrJava Developer Documentation. If you are working on CSnet, steps 1 to 3 have already been taken care of when you set up your CSnet account.

You may have to set your CLASSPATH to include the tools.jar file:

You should start YourKit by typing yjp.sh &. Then you start DrJava using:

Now you can click on "Connect to locally running profiled application..." in YourKit.

Profiling Exercise

We will go through an actual application of YourKit to the DrJava codebase using DrJava revision 4175. In the interest of your learning experience, don't look at the Subversion revision comments for revisions 4176 and 4177.

Create a directory for the source code and check out revision 4175. Then build a jar file:

Note that for this version, the jar file that is built is called drjava-15.jar.

Start YourKit and start the drjava-15.jar file:

DrJava should start to open. You can now click on "Connect to locally running profiled application..." in YourKit. After a few seconds, YourKit should display a graph showing CPU utilization.

Open a copy of the MainFrame.java file in DrJava.

In the CPU section on the left, select "Tracing", then push the "Start CPU Profiling" button. Now switch to DrJava, press Ctrl-G to open the "Go to Line" dialog, and type in 9000 as line. Wait until DrJava finishes jumping to that line (which can take quite a while with tracing enabled), then switch back to YourKit and press the "Capture Snapshot" button. Tell YourKit to open this snapshot.

Select "Call tree (by thread)" under "CPU statistics" and start expanding the items for the thread that starts with "AWT-EventQueue". Try to find the bottleneck:

  Profiling  

URL: http://www.cs.rice.edu/~javaplt/402/12-spring/lectures/profiling/index.shtml