6 use Benchmark qw<cmpthese>;
11 my @poultry = (qw<cock chick>);
13 sub Duck::quack { $counter += $_[0]->{id} * $_[0] }
14 sub fly { $counter += $_[0]; }
15 sub Duck::unshift { CORE::unshift @poultry, $_[0]->{id} * $_[3] }
16 sub Duck::pop { CORE::pop @poultry }
18 my $duck = bless { id => 0.7 }, 'Duck';
21 explicit => sub { $duck->quack(3); },
29 direct => sub { fly(2); },
37 core => sub { push @poultry, 1; shift @poultry; },
40 push @poultry, 1; shift @poultry;
45 core => sub { unshift @poultry, $duck->{id} * 5; pop @poultry; },
48 unshift @poultry, -5; pop @poultry;