3 use Benchmark qw(:all);
4 use Config; printf "Perl/%vd in $Config{archname}\n\n", $^V;
8 my $cxsa_is_loaded = eval q{
21 sub new { bless {}, shift }
27 use Mouse::Util::TypeConstraints;
41 has with_tc_class_type => (
46 has with_tc_array_of_int => (
48 isa => 'ArrayRef[Int]',
51 has with_tc_duck_type => (
53 isa => duck_type([qw(simple)]),
55 __PACKAGE__->meta->make_immutable;
60 use Moose::Util::TypeConstraints;
73 has with_tc_class_type => (
77 has with_tc_array_of_int => (
79 isa => 'ArrayRef[Int]',
81 has with_tc_duck_type => (
83 isa => duck_type([qw(simple)]),
86 __PACKAGE__->meta->make_immutable;
89 use B qw(svref_2object);
91 print "Moose/$Moose::VERSION (Class::MOP/$Class::MOP::VERSION)\n";
92 print "Mouse/$Mouse::VERSION\n";
93 print "Class::XSAccessor/$Class::XSAccessor::VERSION\n" if $cxsa_is_loaded;
95 my $mi = MouseOne->new();
96 my $mx = MooseOne->new();
98 $cx = CXSA->new if $cxsa_is_loaded;
100 print "\nSETTING for simple attributes\n";
111 'C::XSAccessor' => sub{
119 print "\nSETTING for attributes with type constraints 'Int' (except for C::XSAccessor)\n";
130 'C::XSAccessor' => sub{
137 print "\nSETTING for attributes with type constraints 'Foo' (except for C::XSAccessor)\n";
141 $mi->with_tc_class_type($foo);
142 $mi->with_tc_class_type($foo);
145 $mx->with_tc_class_type($foo);
146 $mx->with_tc_class_type($foo);
149 'C::XSAccessor' => sub{
156 print "\nSETTING for attributes with type constraints 'ArrayRef[Int]' (except for C::XSAccessor)\n";
161 $mi->with_tc_array_of_int($foo);
162 $mi->with_tc_array_of_int($foo);
165 $mx->with_tc_array_of_int($foo);
166 $mx->with_tc_array_of_int($foo);
169 'C::XSAccessor' => sub{
176 print "\nSETTING for attributes with type constraints duck_type() (except for C::XSAccessor)\n";
178 $foo = MouseOne->new();
181 $mi->with_tc_duck_type($foo);
182 $mi->with_tc_duck_type($foo);
185 $mx->with_tc_duck_type($foo);
186 $mx->with_tc_duck_type($foo);
189 'C::XSAccessor' => sub{