#!perl

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

use 5.010001;
use strict;
use warnings;

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

cmpthese(
    0,
    {
        'DateTime     1k_now' => sub { DateTime    ->now for 1..1000 },
        'Time::Moment 1k_now' => sub { Time::Moment->now 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.01 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::Moment 1k_now Time::Moment 1k_set
 DateTime     1k_set 18.2572+-0.0055/s                  --              -14.4%              -97.7%              -99.2%
 DateTime     1k_now   21.339+-0.022/s        16.88+-0.12%                  --              -97.3%              -99.1%
 Time::Moment 1k_now      777.2+-1.4/s        4157.2+-7.5%        3542.3+-7.4%                  --              -67.4%
 Time::Moment 1k_set    2387.85+-0.3/s            12978.9%          11090+-12%       207.22+-0.54%                  --

=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 (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
