#!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;

my $dt1 = DateTime    ->new(year=>2015, month=>6, day=>19, hour=>14, minute=>7, second=>59, time_zone=>'UTC');
my $dt2 = DateTime    ->new(year=>2015, month=>7, day=> 1, hour=>14, minute=>7, second=>59, time_zone=>'UTC');
my $tm1 = Time::Moment->from_object($dt1);
my $tm2 = Time::Moment->from_object($dt2);

cmpthese(
    0,
    {
        'DateTime     1k_comp2' => sub { DateTime->compare($dt1, $dt2) for 1..1000 },
        'Time::Moment 1k_comp2' => sub { $tm1->compare($tm2)           for 1..1000 },
    },
);

# ABSTRACT: Benchmark date modules: compare date objects
# PODNAME: bench-date-modules-compare

__END__

=pod

=encoding UTF-8

=head1 NAME

bench-date-modules-compare - Benchmark date modules: compare date objects

=head1 VERSION

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

=head1 SYNOPSIS

 % bench-date-modules-compare

Sample output:

                                 Rate DateTime     1k_comp2 Time::Moment 1k_comp2
 DateTime     1k_comp2 141.96+-0.13/s                    --                -98.5%
 Time::Moment 1k_comp2     9343+-19/s             6481+-15%                    --

=head1 DESCRIPTION

comp2: Compare 2 date objects with compare() 1000 times.

=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
