[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] benchmark and md5sum




On May 14, 2006, at 10:44 AM, Dave M wrote:

I often use the same md5 subroutine in all my scripts for various
reasons. Recently I saw another way to read it in, and it appears to
be faster:

The #1 rule of benchmarking is to pull out as much irrelevant stuff as you can.  For instance, the check for -d $file should be done outside of the benchmarked functions.  It's the same in both functions, and skew your results.  What if that check for the directory turns out to be 90% of the runtime in both cases?

Other than that, I don't see anything else to pull out, though.

You might want to try this:

                my $slurp  = do { local $/; <FH> };
                my $md5sum = Digest::MD5::md5_hex($slurp);

as

                local $/;
                my $md5sum = Digest::MD5::md5_hex(<FH>);

This removes the assignment of a local variable which you're then going to copy.

xoa



--
Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance