FAQ
We had some date routines in Slash that were just way too slow. When I
started working on this code it used Date::Manip, and I never bothered
to see how it compared speedwise to the modules I had always used,
Date::Parse and Date::Format. So I did a benchmark this morning on my
PowerBook G3/400 (Mac OS 9.1).

#!/usr/bin/perl -w
use strict;
BEGIN { $ENV{TZ} = "GMT" }
use Date::Manip qw(UnixDate DateCalc);
use Date::Parse;
use Date::Format;
use Benchmark;
use vars qw($date $off_set $format $dm $dp);

$date = "2000-01-25 17:36:15";
$off_set = "-14400";
$format = "%A %B %d, @%H:%M";

timethese(1000, {
manip => <<'EOT',
$dm = DateCalc($date, "$off_set SECONDS");
$dm = UnixDate($dm, $format);
EOT
parse => <<'EOT',
$dp = str2time($date) + $off_set;
$dp = time2str($format, $dp);
EOT
});

print $dm, "\n";
print $dp, "\n";

__END__

Benchmark: timing 1000 iterations of manip, parse...
manip: 16 secs (16.63 usr 0.00 sys = 16.63 cpu)
parse: 2 secs ( 1.45 usr 0.00 sys = 1.45 cpu)
Tuesday January 25, @13:36
Tuesday January 25, @13:36

Yikes!

I went up to 10,000 iterations, and tried on an Intel Linux box, with
similar results: for the above operations, Date::Manip is about 15x
slower than Date::Parse + Date::Format.

Enjoy,

--
Chris Nandor pudge@pobox.com http://pudge.net/
Open Source Development Network pudge@osdn.com http://osdn.com/

Search Discussions

  • Alessio Bragadini at Aug 7, 2001 at 3:44 pm

    Chris Nandor wrote:

    I went up to 10,000 iterations, and tried on an Intel Linux box, with
    similar results: for the above operations, Date::Manip is about 15x
    slower than Date::Parse + Date::Format.
    Well, the author says so in the documentation...

    --
    Alessio F. Bragadini alessio@albourne.com
    APL Financial Services http://village.albourne.com
    Nicosia, Cyprus phone: +357-2-755750

    "It is more complicated than you think"
    -- The Eighth Networking Truth from RFC 1925
  • Chris Nandor at Aug 8, 2001 at 1:29 am
    In article <3B6FFA82.AA843540@albourne.com>,
    alessio@albourne.com (Alessio Bragadini) wrote:
    Chris Nandor wrote:
    I went up to 10,000 iterations, and tried on an Intel Linux box, with
    similar results: for the above operations, Date::Manip is about 15x
    slower than Date::Parse + Date::Format.
    Well, the author says so in the documentation...
    I was asked to post the benchmark, so I did.

    --
    Chris Nandor pudge@pobox.com http://pudge.net/
    Open Source Development Network pudge@osdn.com http://osdn.com/
  • Nat Irons at Aug 7, 2001 at 7:15 pm
    In article <pudge-3BB0C4.10082407082001@onion.valueclick.com>,
    pudge@pobox.com (Chris Nandor) wrote:
    I went up to 10,000 iterations, and tried on an Intel Linux box, with
    similar results: for the above operations, Date::Manip is about 15x
    slower than Date::Parse + Date::Format.
    True enough, but at least Date::Manip is up-front about its speed issues
    in the documentation. I got started with it, and eventually moved over
    to Date::Calc for a calendar project that needed more speed.

    -nat

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdatetime @
categoriesperl
postedAug 7, '01 at 2:08p
activeAug 8, '01 at 1:29a
posts4
users3
websitemetacpan.org...

People

Translate

site design / logo © 2019 Grokbase