How can I measure the performance of my code with high precision and fine granularity?

Larry Widing

The method I would recommend is to use a third party tool to perform the profiling for you. While you can use the -prof option for the java command (-Xprof in 1.3), it will produce a simple report to the console which will not give you as complete of a picture as the tools listed below.

The first tool, and the one I have used for over a year, and recommend, is NuMega's TrueTime profiler. It tracks not only how much time was spent in a function, but tracks individual source lines, and how that time was accounted for by different callers to that function.

The second tool is KL Group's JProbe. This tool also provides some very good reports. I have not used this much, as I found TrueTime met my needs, so I did not look any further, but either one should do the job.