Commit | Line | Data |
43123819 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Benchmark qw[cmpthese]; |
7 | |
8 | { |
9 | package Foo; |
10 | use Moose; |
11 | use Moose::Util::TypeConstraints; |
12 | |
13 | has 'baz' => (is => 'rw'); |
14 | has 'bar' => (is => 'rw', isa => 'Foo'); |
15 | has 'boo' => (is => 'rw', isa => type 'CustomFoo' => where { blessed($_) && $_->isa('Foo') }); |
16 | } |
17 | |
18 | my $foo = Foo->new; |
19 | |
20 | cmpthese(200_000, |
21 | { |
22 | 'w/out_constraint' => sub { |
23 | $foo->baz($foo); |
24 | }, |
25 | 'w_constraint' => sub { |
26 | $foo->bar($foo); |
27 | }, |
28 | 'w_custom_constraint' => sub { |
29 | $foo->boo($foo); |
30 | }, |
31 | } |
32 | ); |
33 | |
34 | 1; |