in reply to how to improve the performance of a perl program
- Ok, this one I discussed in an earlier reply.
- Faster accessors.... Do you know which portions of code are causing problems? Faster accessors only make sense if you've got a slow one causing you trouble. And even then, "trimming cycles" is often much less effective than "a more efficient algorithm"
- Yes, I would suggest avoiding calling any code that doesn't do anything. Especially if it does nothing in O(n^2) time. ;) How to detect that it's not doing anything? I guess you've got to look at what it's designed to do, ask why that's useful, and if you determine that it's not doing anything useful, stop calling it. A good regression test suite is helpful when doing that sort of refactoring.
- Exiting loops early is an optimization on a linear operation. Lazy initialization or lazy evaluation is a technique where you do some expensive work just in time, with the hope that maybe you never have to do it at all. If you know you've got to do it, sometimes an opposite technique of pulling as much of the work into startup time as possible can also be beneficial. Which is best for your application has to be your decision based on a lot of factors.
- If you're going to go about rearranging code that does work but just looks silly, especially when it's not really impacting performance, be sure that you've got good regression tests in place first, or just leave it alone.