good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
The problem with premature optimization...by nferraz (Monk) |
on Jun 11, 2007 at 11:07 UTC ( [id://620462]=note: print w/replies, xml ) | Need Help?? |
You're talking about a sub which can be executed 300 thousand times per second, which means it will take something like 3 microseconds of computer time each time it is called. If you "optimize" it, it will take 1-2 microseconds; if you do more checking and validation, which actually improves your program, it will take 5-10 microseconds. Now, take a look on the rest of your program: accessing the database, processing your data, rendering the template probably take a another hundreds or thousands of microseconds! The fact is that, no matter how much you "optimize" this sub -- you could make it instantaneously-fast, or even remove it, and it wouldn't have a significant impact on the global performance at all.
Moreover, if someone actually considers the idea of removing functionality to improve the local performance, that's the perfect example of premature optimization being the root of all evil.
In Section
Seekers of Perl Wisdom
|
|