In case anyone's curious as to the actual benchmark results...

Time::Local is a 4400% speedup. I was expecting a lot, but that's a lot more than I expected.

It looks like regexp based timelocal_nocheck() is 3% faster than the unpack() version -- that could be because of my unnecessary assignment. Neat. I like that Benchmark module.

sub datemanip { &UnixDate(&ParseDate($date), '%s') } sub r_timelocal { $date =~ m/^([A-Z][a-z]{2}) (\d{2}) (\d{2}):(\d{2 +}):(\d{2})$/; timelocal($5, $4, $3, $2, $month{$1}, 2005) } sub r_timelocal_nc { $date =~ m/^([A-Z][a-z]{2}) (\d{2}) (\d{2}):(\d{2 +}):(\d{2})$/; timelocal_nocheck($5, $4, $3, $2, $month{$1}, 20 sub u_timelocal_nc { my @a = reverse unpack('A3xA2xA2xA2xA2', $date); +$a[$#a] = $month{$a[$#a]}; timelocal_nocheck(@a, 2005); } Date::Manip: 768 wallclock secs (636.70 usr + 3.83 sys = 640.53 CPU) +@ 156.12/s (n=100000) r timelocal: 20 wallclock secs (14.86 usr + 0.10 sys = 14.96 CPU) @ 6 +684.49/s (n=100000) r timelocal nc: 16 wallclock secs (14.40 usr + 0.06 sys = 14.46 CPU) +@ 6915.63/s (n=100000) u timelocal nc: 20 wallclock secs (14.80 usr + 0.08 sys = 14.88 CPU) +@ 6720.43/s (n=100000) Rate Date::Manip r timelocal u timelocal nc r ti +melocal nc Date::Manip 156/s -- -98% -98% + -98% r timelocal 6684/s 4182% -- -1% + -3% u timelocal nc 6720/s 4205% 1% -- + -3% r timelocal nc 6916/s 4330% 3% 3% + --

In reply to Re: Fast date parsing by jettero
in thread Fast date parsing by jettero

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.