|
Finding the performance problemsResolving performance problems can be a straightforward process ... if you have the right tools at your disposal. Borrowing directly from the excellent text ``Java Performance Tuning'' by Jack Shirazi, the basic process is:
Or, my simplified version of the process:
The reason I say ``fix the bottlenecks that are causing the biggest problems and don't worry about the others'' is that when you first start, you may see three bottlenecks like this:
(Note that this is greatly simplified here.) What might happen is that if you fix the first problem shown in this list - the examineContents() method - problems 2 and 3 may no longer matter. It may be that the first method was calling the second and third methods quite a bit, but once you fix the first method the second and third are not called nearly as much, and hence become less of a bottleneck than they were.. So, don't worry about 2 and 3 at this point. Just fix #1, because that's your biggest problem, and fixing #1 may totally change your next profile. In the following sections I'll demonstrate how easy it was to cure major performance problems with the devdaily.com EmailAgent. The performance problems with my application were very difficult to troubleshoot without tools, primarily because there was no user interface. Sometimes when you have a GUI you can at least get a feel for what module might be slow, but with a command line program like this one that runs and then returns without comment whenever it is finished, it can be very hard to know where the bottleneck is, especially if you're not comfortable with the problem domain. In this case I had never written a mail client before, and really had no experience or guess as to where the slowness problem might be coming from. The only way to work this out was to run Optimizeit on my program, and see what insights it would reveal.
Next: The first run - Up: Optimizing your first project Previous: Optimizing your first project |