Hi,
I have been converting a couple of programs that were using Time::Piece as
their date/time handling module, to use DateTime.pm instead.
However it seems that DateTime.pm apears to be about 700 times slower
than Time::Piece when parsing dates.
The little program below takes 15 seconds to do 10,000 calls to the new
strptime and only 2 seconds to do 100,000 (ie 10x more) calls to the old
version (on my machine).
Is this something to do with Time::Piece using a C library and DateTime
doing things in perl instead? Or is there some otherway of doing this date
parsing using DateTime that is faster?
Robin
-------------------------------------------------
#!/usr/bin/perl -w
use strict;
use DateTime ;
use DateTime::Format::Strptime qw{strptime};
use Time::Piece;
print gmtime->datetime, "\n";
for (my $i =0; $i <=10_000; $i++) {
my $file_datetime = strptime("%Y-%m-%dT%H%M%S", "2004-10-10T101010");
}
print gmtime->datetime, "\n";
for (my $i =0; $i <=100_000; $i++) {
my $file_datetime = Time::Piece -> strptime("2004-10-10T101010",
"%Y-%m-%dT%H%M%S");
}
print gmtime->datetime, "\n";
exit;