use Benchmark (); sub argless { $a cmp $b } sub proto($$) { $_[0] cmp $_[1] } sub args { $_[0] cmp $_[1] } my @array = qw( Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. ); Benchmark::cmpthese(0, { inline => sub { my @sorted = sort { $a cmp $b } @array; }, argless => sub { my @sorted = sort argless @array; }, proto => sub { my @sorted = sort proto @array; }, args => sub { my @sorted = sort { args($a, $b) } @array; }, }); __END__ Rate args proto argless inline args 4634/s -- -57% -63% -81% proto 10735/s 132% -- -14% -57% argless 12462/s 169% 16% -- -50% inline 24920/s 438% 132% 100% -- #### use Benchmark (); sub argless { $hash{$a } cmp $hash{$b } } sub proto($$) { $hash{$_[0]} cmp $hash{$_[1]} } sub args { $hash{$_[0]} cmp $hash{$_[1]} } our %hash = map { (''.rand()) => $_ } qw( Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. ); Benchmark::cmpthese(0, { inline => sub { my @sorted = sort { $hash{$a} cmp $hash{$b} } keys %hash; }, argless => sub { my @sorted = sort argless keys %hash; }, proto => sub { my @sorted = sort proto keys %hash; }, args => sub { my @sorted = sort { args($a, $b) } keys %hash; }, }); __END__ Rate args proto argless inline args 2832/s -- -33% -42% -43% proto 4258/s 50% -- -13% -14% argless 4871/s 72% 14% -- -2% inline 4973/s 76% 17% 2% --