#!/usr/bin/perl

use warnings;
use strict;

use DateTime;
use DateTime::Sort::Key;

use Benchmark qw(cmpthese);

my @tz=qw(UTC Europe/Madrid Asia/Taipei America/Los_Angeles);

for (10, 100, 1000, 5000, 100000) {
    my @unsorted = map { DateTime->new( year => 1900+int rand(20),
					month => 1+int rand(12),
					day => 1+int rand(28),
					hour => int rand(24),
					minute => int rand(60),
					second => int rand(60),
					time_zone => $tz[int rand(@tz)] ) } 0..$_;

    cmpthese(-1, { "sort $_" => sub { (sort @unsorted)[0] },
		   "dtkeysort $_" => sub { (dtkeysort {$_} @unsorted)[0] } } );

}
