Skip to content

Instantly share code, notes, and snippets.

@ggl
Created December 4, 2013 13:15
Show Gist options
  • Save ggl/7787248 to your computer and use it in GitHub Desktop.
Save ggl/7787248 to your computer and use it in GitHub Desktop.
Time::Piece and Class::Date benchmarked
#!/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