X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=benchmarks%2Ftype_constraints.pl;h=e9b29f869a2c763a343ae60f193dc6bb676de562;hb=4513d67edb939e4036ea2297ac8d4749726a45a8;hp=2e87d83dd719a929422d524fcacb4c1b8e60c741;hpb=8ecb1fa00856ddb07f4e006c79fe4c48e08902c0;p=gitmo%2FMoose.git diff --git a/benchmarks/type_constraints.pl b/benchmarks/type_constraints.pl index 2e87d83..e9b29f8 100644 --- a/benchmarks/type_constraints.pl +++ b/benchmarks/type_constraints.pl @@ -7,8 +7,8 @@ use Benchmark qw[cmpthese]; =pod -This benchmark compares the overhead of a -auto-created type constraint vs. none at +This benchmark compares the overhead of a +auto-created type constraint vs. none at all vs. a custom-created type. =cut @@ -17,17 +17,16 @@ all vs. a custom-created type. package Foo; use Moose; use Moose::Util::TypeConstraints; - + has 'baz' => (is => 'rw'); has 'bar' => (is => 'rw', isa => 'Foo'); - #has 'boo' => (is => 'rw', isa => type 'CustomFoo' => where { blessed($_) && $_->isa('Foo') }); } { package Bar; - + sub new { bless {} => __PACKAGE__ } - sub bar { + sub bar { my $self = shift; $self->{bar} = shift if @_; $self->{bar}; @@ -37,7 +36,7 @@ all vs. a custom-created type. my $foo = Foo->new; my $bar = Bar->new; -cmpthese(200_000, +cmpthese(200_000, { 'hand coded' => sub { $bar->bar($bar); @@ -46,11 +45,8 @@ cmpthese(200_000, $foo->baz($foo); }, 'w_constraint' => sub { - $foo->bar($foo); + $foo->bar($foo); }, - #'w_custom_constraint' => sub { - # $foo->boo($foo); - #}, } );