At Windward Wrocks David Thielen talks about an alternative to profilers that can be used in many situations.
The way we're all taught to profile is you install a profiler like YourKit and then run your code under it. It shows you the hotspots and you dive in to that code to figure out how to optimize it. This is a great approach for many cases. I've used it myself a lot, especially back when I did game programming.
However, there are a lot of times where a much easier approach is equally effective. And for some cases, much more effective. It's fast, it's simple, and it gets the job done. What is it?
- Start your program under the debugger.
- Every 10 seconds hit pause in the debugger. Record where you are in the program.
- After doing this 5 – 10 times, stop.
For a great many situations you will find that of the 10 times you broke into the program, it is in the same code each time. You now know where the code is spending its time. And you did this without installing a profiler, without running it, without having to dive into its results.
Continued at Windward Wrocks