Created
September 4, 2016 16:56
-
-
Save tokubass/ab182191913b101ed87a7048dc037048 to your computer and use it in GitHub Desktop.
timepieceとDateCalcの速度比較。昔はtimepieceが遅かったらしいが、今は逆転している。
This file contains 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 | |
use strict; | |
use warnings; | |
use Time::Piece; | |
use Time::Seconds; | |
use Date::Calc; | |
use Benchmark qw(cmpthese); | |
warn $^V; | |
warn 'Time::Piece version: ', $Time::Piece::VERSION; | |
warn 'Date::Calc version: ', $Date::Calc::VERSION; | |
my $t = Time::Piece::localtime(); | |
sub a { | |
my $t2 = $t + Time::Seconds::ONE_DAY; | |
$t2->strftime('%Y-%m-%d %H:%M:%S'); | |
} | |
my @t = Date::Calc::Today_and_Now(); | |
sub c { | |
my @t2 = Date::Calc::Add_Delta_DHMS(@t, 1, 0, 0, 0); | |
sprintf('%d-%02d-%02d %02d:%02d:%02d', @t2); | |
} | |
cmpthese(-1, { | |
'Time::Piece' => 'a', | |
'Date::Calc' => 'c', | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment