Background

Remember that most computers spend virtually all their time waiting for the user to do something... and most of the rest of the time waiting for another computer, a network, or I/O device to do something! Developers are notoriously bad at guessing where time is actually spent, so it's a good idea always to do some measurements before writing contorted or difficult to maintain code in the supposed interests of performance.

Profiling techniques

There are several techniques for profiling Java code:

Caveats

Any of the techniques that trap method calls will lead to slight distortions in the timing as native methods or code involving system calls will execute at normal speed wheras code involving many Java method calls will be slowed by nearly a factor of three.

Why is so much time spent in Object.wait()? This is where a thread spends all its time when it's waiting for another thread to finish or for I/O to complete, including waiting for the user to press a key or move the mouse, so it's almost always guaranteed to be the method at the top of the list. In general, you won't get any very meaningful results from analysing the wait() method and should start instead by analysing a method you know is significant in your code.

History

This application was originally a Perl script, then given a user interface in early 1998 when Swing was still in beta and using the com.sun.swing package name. Only recently was the dust brushed off, a standalone version of the Java2 collection classes added (so it runs with JDK1.1.8 releases), and then made available for download.


Help index | Start over