my $self = shift;
my %param = @_;
####
my ($self,%param) = @_;
##
##
use Benchmark qw(cmpthese);
cmpthese( -2,{
list => sub { my ($self,%param) = @_ },
shiftit => sub { my $self = shift; my %param = @_ },
} );
__END__
5.8.3 Rate list shiftit
list 78392/s -- -73%
shiftit 292680/s 273% --
5.6.2 Rate list shiftit
list 94936/s -- -68%
shiftit 297717/s 214% --
##
##
sub list { my ($self,%param) = @_ }
sub shiftit { my $self = shift; my %param = @_ }
cmpthese( -2,{
list => sub { list( qw(foo bar baz) ) },
shiftit => sub { shiftit( qw(foo bar baz) ) },
} );
__END__
5.8.3 Rate shiftit list
shiftit 70621/s -- -11%
list 79125/s 12% --
5.6.2 Rate shiftit list
shiftit 89341/s -- -10%
list 98866/s 11% --
##
##
cmpthese( -2,{
list => sub { list( qw(foo) ) },
shiftit => sub { shiftit( qw(foo) ) },
} );
__END__
5.8.3 Rate shiftit list
shiftit 164545/s -- -19%
list 204158/s 24% --
5.6.2 Rate shiftit list
shiftit 179408/s -- -12%
list 203990/s 14% --
##
##
cmpthese( -2,{
list => sub { list() },
shiftit => sub { shiftit() },
} );
__END__
5.8.3 Rate shiftit list
shiftit 217350/s -- -12%
list 247334/s 14% --
5.6.2 Rate shiftit list
shiftit 212031/s -- -14%
list 246447/s 16% --
##
##
To call subroutines:
NAME(LIST); # & is optional with parentheses.
NAME LIST; # Parentheses optional if predeclared/imported.
&NAME(LIST); # Circumvent prototypes.
&NAME; # Makes current @_ visible to called subroutine.
##
##
cmpthese( -2,{
list => sub { &list },
shiftit => sub { &shiftit },
} );
__END__
5.8.3 Rate list shiftit
list 126315/s -- -62%
shiftit 333577/s 164% --
5.6.2 Rate list shiftit
list 135814/s -- -61%
shiftit 343986/s 153% --