I definitely think benchmarking is the key answer here.
I think no matter what, this is an implementation specific problem. I always wrote Perl for
programmer speed, and paid less attention to execution speed. Until I started working on problems
that were big enough to deal with datasets ranging from hundreds of meg to a few gig in size.
I love Perl but for data this big, and the bit of processing required, I would have initially went
with either C or C++. BUT - I work in a place where most everyone knows Perl and not many know C/C++
so Perl optimization has become a big issue.
I've learned a lot about how slight code changes can increase efficiency, especially when
certain tasks need to be done many times over. I've seen major speed increases
just by benchmarking and trying a different solution, but keeping the same algorithm.
Things especially like
my @a = ();
if ( $foo =~ /^(\d+)\s+(\w+)\s*$/ ) {
@a = ($1, $2);
}
vs.
my @a = split (/\s+/, $foo);
Guess what? In my system, option #1 runs about 90% faster.
-felonious
--