use strict; #use warnings; #no warnings 'redefine'; #use Smart::Comments::JSON '##'; use Benchmark qw(:all) ; my $count = 3000; my $ENABLE_UNUSE = 0; sub unuse { my $pat = shift; return if !$ENABLE_UNUSE; for my $key (keys %INC) { if ($key =~ $pat) { #warn $key; delete $INC{$key}; } } } my $moose_code = q!unuse(qr/^Moose/);eval q{package FooA;use Moose;has x=>(is=>'rw');has y=>(is=>'rw')};die $@ if $@!; my $fast_code = q!unuse(qr/^Class\//);eval q{package FooB;use base "Class::Accessor::Fast";__PACKAGE__->mk_accessors(qw/x y/);};die $@ if $@!; my $accessor_code = q!unuse(qr/^Class\//);eval q{package FooC;use base "Class::Accessor";__PACKAGE__->mk_accessors(qw/x y/);};die $@ if $@!; my $xs_code = q!unuse(qr/^Class\//);eval 'package FooD;use Class::XSAccessor accessors=>{x=>"x",y=>"y"},replace=>1;';die $@ if $@!; ## $moose_code ## $fast_code ## $accessor_code ## $xs_code cmpthese($count, { 'Moose' => $moose_code, 'Class::Accessor::Fast' => $fast_code, 'Class::Accessor' => $accessor_code, 'Class::XSAccessor' => $xs_code, });