> -----Original Message-----
> From: Rick Measham [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, April 23, 2006 8:13 PM
> To: Garrett, Philip (MAN-Corporate)
> Cc: datetime@perl.org
> Subject: Re: from_epoch for DateTime::LazyInit?
>
>
> P.S. if you want to run benchmarking on the overloading, and it shows
>      that it doesn't increase load or creation time(span) of DT:LI
>      objects I'm willing to reconsider, but I'm a bit loathe :)

There is no discernible difference with the overloading. Not sure what
you mean by "load" time but if it's module load time you're worried
about, DateTime::LazyInit requires DateTime which requires overload --
this doesn't load any modules that weren't already loaded.

With overload:

$ ./bench.pl 100000
Benchmark: timing 100000 iterations of create_and_inflate,
create_only...
create_and_inflate: 42 wallclock secs (41.91 usr +  0.09 sys = 42.00
CPU) @ 2380.95/s (n=100000)
create_only:  2 wallclock secs ( 1.46 usr +  0.01 sys =  1.47 CPU) @
68027.21/s (n=100000)

Without overload:

$ ./bench.pl 100000
Benchmark: timing 100000 iterations of create_and_inflate,
create_only...
create_and_inflate: 43 wallclock secs (43.16 usr +  0.11 sys = 43.27
CPU) @ 2311.07/s (n=100000)
create_only:  2 wallclock secs ( 1.45 usr +  0.03 sys =  1.48 CPU) @
67567.57/s (n=100000)

I ran this several times.  Each time the results were slightly
different.  Sometimes the code with overloads was faster than the code
without, and vice versa.  The time averaged at about the same (68k/s)
with both versions.

The script:

#!/usr/bin/env perl
use strict;
use warnings;
use Benchmark qw(timethese);
use DateTime::LazyInit;


timethese( @ARGV, {
    create_only => '
        my $dtli = DateTime::LazyInit->from_epoch( epoch => time );
    ',
    create_and_inflate => '
        my $dtli = DateTime::LazyInit->from_epoch( epoch => time );
        $dtli->__inflate("epoch");
    ',
});

Reply via email to