X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=benchmarks%2Ftype_constraints2.pl;fp=benchmarks%2Ftype_constraints2.pl;h=c041d2620950a462d2d7e75b84af9222d8c68a2b;hb=d6a56f38081530688e1c5bdf352e384d220202f6;hp=688360a32d21c4c77a7b73c835fe05c66ba04d89;hpb=a965b6da59987429b38cfcb1274d87c57f3f1e8b;p=gitmo%2FMoose.git 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] );