Created
December 4, 2013 13:15
-
-
Save ggl/7787248 to your computer and use it in GitHub Desktop.
Time::Piece and Class::Date benchmarked
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# | |
# Time::Piece and Class::Date benchmarked | |
# | |
use strict; | |
use warnings; | |
use Benchmark qw(cmpthese); | |
use Time::Piece; | |
use Class::Date qw(date); | |
my @ts = ('2013-12-04 11:00:36', '2013-12-04 12:09:33'); | |
cmpthese -2, { | |
timepiece => sub { | |
my @t; | |
push @t, Time::Piece->strptime($_, "%Y-%m-%d %H:%M:%S") for @ts; | |
my $ret = $t[0] <= $t[1] ? 1 : 0; | |
return $ret; | |
}, | |
classdate => sub { | |
my @t; | |
push @t, Class::Date::date($_) for @ts; | |
my $ret = $t[0] <= $t[1] ? 1 : 0; | |
return $ret; | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment