I really don't like Date::Manip. Sure it does a
lot, but that's it's downfall. In tests I've seen it take
fifteen times as long to do simple date manipulations than
an equivalent script written using Perl's built-in
functions.
There are times when that's a worthwhile hit to take,
but in cases like this where it's very simple to do with
built-ins I really don't think it's worthwhile.
--
<http://www.dave.org.uk>
"The first rule of Perl club is you don't talk about
Perl club."
| [reply] [Watch: Dir/Any] |
Sure, Date::Manip is slow compared to hand-rolled stuff.
It even says so in the POD (see below). So there is no
reason to complain about this, you have been warned.
OTOH, I really think re-solving all those common date calculating problems again and again is a big waste of time,
and a big source of errors in programs, too.
From the Date::Manip POD:
Date::Manip is certainly the most powerful of the Date modules.
To the best of my knowledge, it will do everything that any
other date module will do (not just the ones I listed above),
and there are a number of features that Date::Manip has that
none of the other modules have. Date::Manip is the "Swiss Army
Knife" of Date modules. I'm trying to build a library which can
do _EVERY_ conceivable date/time manipulation that you'll run
into in everyday life.
Although I am working on making Date::Manip faster, it will
never be as fast as other modules. And before anyone asks,
Date::Manip will never be translated to C (at least by me). I
write C because I have to. I write perl because I like to.
Date::Manip is something I do because it interests me, not
something I'm paid for.
Date::Manip is also big. The last time I looked, it's one of the
largest CPAN modules there is. If you ignore modules like Tk,
LWP, etc. which are actually packages of modules, it may be the
largest. It's true that Date::Manip will do almost every date
operation you could imagine... but you rarely need all that
power. I'm working on reducing the footprint of Date::Manip, but
even at it's slimmest, it'll outweigh the other modules by a
good bit.
If you are going to be using the module in cases where
performance is an important factor (started up in a CGI program
being run by your web server 5,000 times a second), you should
check out one of the other Date or Time modules in CPAN. If
you're only doing fairly simple date operations (parsing common
date formats, finding the difference between two dates, etc.),
the other modules will almost certainly suffice. If you're doing
one operation very repetitively (parsing 10,000 dates from a
database), you are probably better off writing your own
functions (perhaps bypassing all date modules entirely) designed
specifically for your needs.
On the other hand, if you want one solution for all your date
needs, don't need peak speed, or are trying to do more exotic
date operations, Date::Manip is for you. Operations on things
like business dates, foreign language dates, holidays and other
recurring events, etc. are available more-or-less exclusively in
Date::Manip.
Christian Lemburg
Brainbench MVP for Perl
http://www.brainbench.com | [reply] [Watch: Dir/Any] [d/l] |