Don’t Optimize Code -- Benchmark It
-- from Ten Essential Development Practices by Damian Conway
The real problem is that programmers have spent far too much time worrying about efficiency in the wrong places and at the wrong times; premature optimization is the root of all evil (or at least most of it) in programming
-- Donald Knuth
No one has yet linked to Devel::NYTProf. It's a great tool to find out where your code really wastes CPU and time. Just run your script like this ...
perl -d NYTProf yourscript.pl foo bar baz
... followed by ...
nytprofhtml --open
... and look for the code that takes the longest time to run. That's where you want to start optimizing.
Commit your current version to git/SVN/CVS/whatever, modify, run through NYTProf again until speed improves. Revert and retry if speed goes down. Commit, re-profile, opimize the next top problem from NYTProf. Stop when the code is sufficiently fast.
Alexander
In reply to Re^4: looping efficiency
by afoken
in thread looping efficiency
by Anonymous Monk
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |