Recently i had a choice between two modules, Date::Manip, and Date::Pcalc (a perl version of Date::Calc). I originally went with Manip, but someone pointed out that manip was supposed to be slower, so i went out and benchmarked them, and came up with:
use Benchmark; timethese(10_000,{ 'Pcalc' => sub { require Pcalc; my $date=20020428182540; my @date; push @date,substr($date,0,4,''); for my $i(0..int (length $date)/2){push @date,substr($date,0,2,'') +;} pop @date; my @diff=reverse Date::Pcalc::Delta_DHMS(@date,Date::Pcalc::Today_ +and_Now()); return "[$diff[0]s:$diff[1]m:$diff[2]h:$diff[3]d]";}, 'manip' => sub{ require Manip; $main::TZ='EST'; my $d1=Date::Manip::ParseDate(20020428182540); my $d2=Date::Manip::ParseDate('today'); my $err; my $delta=Date::Manip::DateCalc($d2,$d1,\$err,1); my $first=substr($delta,0,1,''); my @d=reverse split /:/,$delta; return ($first eq '-')? "[$d[0]s:$d[1]m:$d[2]h] $d[3]d-$d[5]m-$d[6]y": "This was posted in the future. Bummer. Odd aint it?";} })
Which gave me the following results:
Benchmark: timing 10000 iterations of Pcalc, manip... Pcalc: 2 wallclock secs ( 1.98 usr + 0.00 sys = 1.98 CPU) @ 5050.51/s (n=10000) manip: 49 wallclock secs (49.10 usr + 0.00 sys = 49.10 CPU) @ 203.67/s (n=10000)
Now, even realizing that manip is supposed to be slower, Thats a rather extreme difference. Anyone else have useful module benchmarks to share in the context of choosing one over the other?

Replies are listed 'Best First'.
Re: Module benchmarks...
by blakem (Monsignor) on May 02, 2002 at 05:58 UTC
    This would be a good time to point out the Should I Use Date::Manip section in the docs, which starts off:
    If you look in CPAN, you'll find that there are a number of Date and Time packages. Is Date::Manip the one you should be using? In my opinion, the answer is no most of the time. This sounds odd coming from the author of the software, but read on.

    Date::Manip is written entirely in perl. It's the most powerful of the date modules. It's also the biggest and slowest.

    Follow the link above to read the authors full statement.

    -Blake

    A reply falls below the community's threshold of quality. You may see it by logging in.