#!perl

our $DATE = '2015-06-19'; # DATE
our $VERSION = '0.02'; # VERSION

use 5.010001;
use strict;
use warnings;

use Benchmark::Dumb qw(cmpthese);
use DateTime;
use Time::Moment;
use Time::Piece ();

cmpthese(
    0,
    {
        'DateTime     1k_now' => sub { DateTime    ->now for 1..1000 },
        'Time::Moment 1k_now' => sub { Time::Moment->now for 1..1000 },
        'Time::Piece  1k_now' => sub { Time::Piece::gmtime for 1..1000 },

        'DateTime     1k_set' => sub { DateTime    ->new(year=>2015, month=>6, day=>19, hour=>14, minute=>7, second=>59) for 1..1000 },
        'Time::Moment 1k_set' => sub { Time::Moment->new(year=>2015, month=>6, day=>19, hour=>14, minute=>7, second=>59) for 1..1000 },
    },
);

# ABSTRACT: Benchmark date modules: generate date objects
# PODNAME: bench-date-modules-gen

__END__

=pod

=encoding UTF-8

=head1 NAME

bench-date-modules-gen - Benchmark date modules: generate date objects

=head1 VERSION

This document describes version 0.02 of bench-date-modules-gen (from Perl distribution App-BenchDateModules), released on 2015-06-19.

=head1 SYNOPSIS

 % bench-date-modules-gen

Sample output:

                                Rate DateTime     1k_set DateTime     1k_now Time::Piece  1k_now Time::Moment 1k_now Time::Moment 1k_set
 DateTime     1k_set 17.929+-0.019/s                  --              -14.8%              -88.7%              -97.8%              -99.1%
 DateTime     1k_now 21.055+-0.027/s        17.43+-0.19%                  --              -86.7%              -97.4%              -99.0%
 Time::Piece  1k_now  158.65+-0.46/s         784.9+-2.7%         653.5+-2.4%                  --              -80.2%              -92.1%
 Time::Moment 1k_now    803.2+-2.6/s           4380+-15%           3715+-13%         406.3+-2.2%                  --              -60.1%
 Time::Moment 1k_set   2014.8+-5.6/s          11137+-34%           9469+-29%        1169.9+-5.1%         150.8+-1.1%                  --

=head1 DESCRIPTION

1k_set: Generate a thousand date objects of a specific
year/month/day/hour/minute/second.

1k_now: Generate a thousand date objects containing current time (e.g. now()).

=head1 SEE ALSO

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/App-BenchDateModules>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-App-BenchDateModules>.

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=App-BenchDateModules>

When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.

=head1 AUTHOR

perlancar <perlancar@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut
