I have written a bit of Java code that does some financial analysis for me. Unfortunately it takes forever to run, even on my dual proc G5 w/a gig of ram it could literally run for over a day (it's those pesky 5 nested for loops, hey don't look at me, the equation it's solving has 12 variables and using some algebra and domain knowledge I could get it down it down to 5 independent variables but at that point I just had to iterate). Thankfully there were lots of obvious optimizations that I could apply that got the program down to around 4 minutes and then making the program multi-threaded got it down to around 3 minutes. But that is still a while to wait. So I decided I wanted to do some performance profiling.
I use Eclipe so it was natural to look a Hyades but the requirements included the Eclipse SDK which, near as I can tell, isn't currently available for OS X and anyway the whole project just seemed a bit complex and what I needed was really simple. I next tried out jMechanic which looked to be at just the right level of sophistication for my needs. Unfortunately it never seemed to quite run right. I would create a profile, run the program, see some hprof output in the console, etc. but when I tried to view the results using window->show view->other->profiler->etc. I never saw any data. I even got various errors from Eclipse.
I briefly considered using a commercial product but come on, my needs are trivial and the commercial stuff is expensive. So finally I decided to look into hprof directly. This is the performance profiling technology built into the JVM. Hprof is more than powerful enough to give me the level of detail I needed but the output is, to put it kindly, a bit hard to read. After looking around for a hprof viewer I found one that seems to do a pretty good job, PerfAnal.
It's very simple and doesn't have many features but it does a good job of providing a view of what the code is doing. This article gives a very nice overview and got me up and running within about two minutes. The end result? It helped me find some snags in my code (I never realized just how incredibly expensive it is to declare arrays in Java and I had left in some error checking code that I no longer needed) which got my performance down to around a minute. So I'm a pretty happy camper.