That’s why visualvm calls those tabs “profilers”, yes. It’s easier than hand-rolling timers and way superior to guesswork. But sometimes you need to log times so you can get an idea of the trend over time. For that I recommend Metrics by the ever-awesome Coda Hale. One annotation on a method is all it takes, and you can use visualvm’s built-in graphing or export it to stuff like ganglia.
Just used two hours to optimize normal from height map(actual its just function) calculation at vertex shader. Was so happy when micro optimized function was two times shorter and faster. Some times optimized code looks ugly but sometimes you can reduce complexity without losing functionality.
JVisualVM is a decent profiler bundled with JDK since… I actually dunno when, I assume jdk5.
When optimizing or looking for performance gains in java land, one should defenitly start by running this tool.
Refactoring is an evolutionary step in the life of the code. There is the refactoring-at-large, which is an overhaul of the design which is a “stop-the-world” process. This is the kind of code maintenance the client doesn’t want to pay for since there is no viewable, touchable benefit, except for the developer.
Then there is the lower refactoring, which is abstracting the code and removing duplications and general health level maintenance. This is the “runtime” proccess, where You can refactor the code while activly developing and as such I’m doing pretty much as soon as I see a need.