From: Jesse Luehrs Date: Mon, 25 Apr 2011 00:42:37 +0000 (-0500) Subject: more benchmarks X-Git-Tag: 2.0100~187 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d6a56f38081530688e1c5bdf352e384d220202f6;p=gitmo%2FMoose.git more benchmarks --- diff --git a/benchmarks/type_constraints2.pl b/benchmarks/type_constraints2.pl index 688360a..c041d26 100644 --- a/benchmarks/type_constraints2.pl +++ b/benchmarks/type_constraints2.pl @@ -81,6 +81,18 @@ inlining type constraints. __PACKAGE__->meta->make_immutable; } +{ + package Simple; + use Moose; + + has str => ( + is => 'rw', + isa => 'Str', + ); + + __PACKAGE__->meta->make_immutable; +} + my @ints = 1 .. 10; my @strs = 'a' .. 'j'; my @fhs = map { my $fh; open $fh, '<', $0 or die; $fh; } 1 .. 10; @@ -92,10 +104,22 @@ my %fhs = map { $_ => $_ } @fhs; my %objects = map { $_ => $_ } @objects; my $thing = Thing->new; +my $simple = Simple->new; + +timethese( + 500_000, { + constructor_simple => sub { + Simple->new( str => $strs[0] ); + }, + accessors_simple => sub { + $simple->str( $strs[0] ); + }, + } +); timethese( - 200_00, { - constructor => sub { + 20_000, { + constructor_all => sub { Thing->new( int => $ints[0], str => $strs[0], @@ -111,7 +135,7 @@ timethese( h_object => \%objects, ); }, - accessors => sub { + accessors_all => sub { $thing->int( $ints[0] ); $thing->str( $strs[0] ); $thing->fh( $fhs[0] );