9 has foo => (is => 'rw');
10 __PACKAGE__->meta->make_immutable();
15 has foo => (is => 'rw');
16 __PACKAGE__->meta->make_immutable();
19 package ClassAccessorFast;
22 use base 'Class::Accessor::Fast';
23 __PACKAGE__->mk_accessors(qw(foo));
26 use Benchmark qw(cmpthese);
28 my $moose = PlainMoose->new;
29 my $mouse = PlainMouse->new;
30 my $caf = ClassAccessorFast->new;
35 Moose => sub { $moose->foo(23) },
36 Mouse => sub { $mouse->foo(23) },
37 ClassAccessorFast => sub { $caf->foo(23) },
42 Moose => sub { $moose->foo },
43 Mouse => sub { $mouse->foo },
44 ClassAccessorFast => sub { $caf->foo },
47 my (@moose, @moose_immut, @mouse, @mouse_immut, @caf_stall);
50 Moose => sub { push @moose, PlainMoose->new(foo => 23) },
51 Mouse => sub { push @mouse, PlainMouse->new(foo => 23) },
52 ClassAccessorFast => sub { push @caf_stall, ClassAccessorFast->new({foo => 23}) },
55 my ( $moose_idx, $mouse_idx, $caf_idx ) = ( 0, 0, 0, 0 );
56 print "\nDESTRUCTION\n";
59 $moose[$moose_idx] = undef;
63 $mouse[$mouse_idx] = undef;
66 ClassAccessorFast => sub {
67 $caf_stall[$caf_idx] = undef;