The first thing you want to do is profile your script.
Use Devel::DProf and/or Devel::SmallProf
to find out which parts of the script are taking the most
time: optimize those first. (It turns out that most
programmers have horrible intuition about which parts of
the code are taking the most time, so profile instead of
guessing.)
Once you have a list of hot-spots, optimize them. The
best way to speed up code is to use a faster algorithm,
especially for large data sets. Have a look around google
for better algorithms. (On small data sets, it's sometimes
best to use a simpler, "slower" algorithm: the faster ones
tend to have high setup costs, and are only faster in the
long run.) Failing that, there are lower-level
optimizations that can be done: iterating over a list with
foreach rather than indexing into it inside a
C-style for loop, for example. (Programming
Perl has a section on code optimization.)
If you've tried all that, and your code's still too
slow, you might be able to post some of it here, tell us
what you've tried, and get further advice.
Two non-Perl solutions: if time is more important than
money, you should consider buying faster hardware. (If your
process is using lots of memory and swapping, even $50 worth
of RAM could make a huge difference if it cuts way down on
disk accesses.) It might also be worth it to re-write your
program in a faster language (C is the canonical example,
but I've had good luck with compiled Haskell lately),
especially if it's doing a lot of number crunching.
--
The hell with paco, vote for Erudil!
:wq
|