use lib 't/lib';
package OldWay;
attr_accessor 'name';
sub new { bless {}, shift }
package NewWay;
attr_accessor 'name';
sub new { bless {}, shift }
package main;
use Benchmark qw(cmpthese);
cmpthese(1000000, {
'OldWay' => sub {
my $obj = OldWay->new;
$obj->name("hi");
},
'NewWay' => sub {
my $obj = NewWay->new;
$obj->name("hi");
}
});