X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=benchmarks%2Ftype_constraints.pl;h=2e87d83dd719a929422d524fcacb4c1b8e60c741;hb=8ecb1fa00856ddb07f4e006c79fe4c48e08902c0;hp=1c53e6e72964bb67a05f348abdfcd51e7d0be92f;hpb=5cf3dbcf66d39c700f7b66a20c9bc7e2bbc025ab;p=gitmo%2FMoose.git diff --git a/benchmarks/type_constraints.pl b/benchmarks/type_constraints.pl index 1c53e6e..2e87d83 100644 --- a/benchmarks/type_constraints.pl +++ b/benchmarks/type_constraints.pl @@ -23,10 +23,25 @@ all vs. a custom-created type. #has 'boo' => (is => 'rw', isa => type 'CustomFoo' => where { blessed($_) && $_->isa('Foo') }); } +{ + package Bar; + + sub new { bless {} => __PACKAGE__ } + sub bar { + my $self = shift; + $self->{bar} = shift if @_; + $self->{bar}; + } +} + my $foo = Foo->new; +my $bar = Bar->new; cmpthese(200_000, { + 'hand coded' => sub { + $bar->bar($bar); + }, 'w/out_constraint' => sub { $foo->baz($foo); },