Re: Moose speed and schedule

[email protected] ("David E. Wheeler")
Newsgroups perl.moose
Message-ID <[email protected]>
On Nov 12, 2006, at 11:51, Jonathan Swartz wrote:

> Results on my 1.5 GHz PowerPC G4:
>
>    swartz> ./bench.pl
>    Using Moose version 0.15, Class::MOP version 0.36,  
> Class::Accessor version 0.27
>    Benchmark: timing 1000 iterations of ClassAccessorPage,  
> MoosePage...
>    ClassAccessorPage:  0 wallclock secs ( 0.02 usr +  0.00 sys =   
> 0.02 CPU) @ 50000.00/s (n=1000)
>                (warning: too few iterations for a reliable count)
>     MoosePage: 22 wallclock secs (18.41 usr +  0.33 sys = 18.74  
> CPU) @ 53.36/s (n=1000)

Yow! Maybe try my Class::Meta module, instead? It has a lot that's  
similar to Moose, and the two will likely be merged eventually  
(assuming that I find the tuits), and it doesn't suffer from this  
problem:

#!/usr/bin/perl -w

use strict;

use Benchmark;
use strict;
use warnings;

{ package ClassMetaPage;
   use Class::Meta::Express;
   class {
       meta 'test';
       ctor 'new';
       has  title => ( type => 'scalar' )
   };
}

{ package ClassAccessorPage;
   use strict;
   use warnings;
   use base qw(Class::Accessor);

   __PACKAGE__->mk_accessors(qw(title));
}

printf "Using Class::Meta version %s, Class::Accessor version %s\n",
     $Class::Meta::VERSION, $Class::Accessor::VERSION;

timethese(100000, {
     'ClassMetaPage' => sub { ClassMetaPage->new(title => 'article') },
     'ClassAccessorPage' => sub { ClassAccessorPage->new({title =>  
'article'}) },
});

On my PowerBook G4 1.33 GHz:

Using Class::Meta version 0.53, Class::Accessor version 0.27
Benchmark: timing 100000 iterations of ClassAccessorPage,  
ClassMetaPage...
ClassAccessorPage:  2 wallclock secs ( 1.17 usr +  0.01 sys =  1.18  
CPU) @ 84745.76/s (n=100000)
ClassMetaPage:  4 wallclock secs ( 3.74 usr +  0.02 sys =  3.76 CPU)  
@ 26595.74/s (n=100000)


Best,

David
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.