-
-
Save hisaichi5518/7781568 to your computer and use it in GitHub Desktop.
time module bench
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
| use Time::Moment; | |
| use DateTime; | |
| use DateTime::Tiny; | |
| use Time::Piece (); | |
| use Time::Piece::Plus (); | |
| use Benchmark qw(:all); | |
| use DateTime::TimeZone; | |
| my $time_zone = DateTime::TimeZone->new(name => "Asia/Tokyo"); | |
| cmpthese -1, { | |
| 'datetime' => sub { | |
| DateTime->now; | |
| }, | |
| with_tz => sub { | |
| DateTime->now(time_zone => $time_zone); | |
| }, | |
| 'moment' => sub { | |
| Time::Moment->now; | |
| }, | |
| tiny => sub { | |
| DateTime::Tiny->now; | |
| }, | |
| piece => sub { Time::Piece::localtime() }, | |
| }; | |
| __END__ | |
| $ perl t.pl | |
| Rate with_tz datetime piece tiny moment | |
| with_tz 6020/s -- -44% -92% -96% -99% | |
| datetime 10811/s 80% -- -85% -92% -98% | |
| piece 74472/s 1137% 589% -- -45% -87% | |
| tiny 135244/s 2147% 1151% 82% -- -77% | |
| moment 583158/s 9587% 5294% 683% 331% -- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment