Though Date::Manip is a really powerful tool, as his author states in the documentation, it's nearly always an overkill to use it in simple tasks.

You should probably want to benchmark Date::Manip with other modules like Date::Calc with the Delta_days() function, which might be what you're looking for.

Update:

I just benchmarked both module and Manip is really slower than Calc (but remember that Calc is not 100% Perl, and Date::Manip parses each time the dates we provide)

Here's the code and the results of the Benchmark, if anyone wants to optimize, criticize, or bencmark with other module:

$d1 = '14', $m1 = '08', $y1 = '2001'; $d2 = '16', $m2 = '12', $y2 = '2001'; $dt1 = "2001/08/14"; $dt2 = "2001/12/16"; timethese(-10, { # running for at least 10 seconds 'Calc' => \&Calc, 'Manip' => \&Manip, }); sub Calc { my $Dd = Date::Calc::Delta_Days($y1,$m1,$d1,$y2,$m2,$d2); } sub Manip { my $date1=Date::Manip::ParseDate($dt1); my $date2=Date::Manip::ParseDate($dt2); my $flag=Date::Manip::Date_Cmp($date1,$date2); }

The results:

Benchmark: running Calc, Manip, each for at least 10 CPU seconds... Calc: 12 wallclock secs (11.04 usr + 0.00 sys = 11.04 CPU) @ 142935.85/s (n=1577440) Manip:10 wallclock secs (10.56 usr + 0.00 sys = 10.56 CPU) @ 104.88/s (n=1107)

Is this making Date::Calc 1300 times faster than Date::Manip?

-- Briac

<kbd>--
PerlMonger::Paris(http => 'paris.pm.org');</kbd>

In reply to Re: Date comparisons + Benchmark by OeufMayo
in thread Date comparisons by cajun

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.