in reply to Re^2: sort routines crossing package lines
in thread sort routines crossing package lines
Not optimisations, errors.
#! perl -slw use strict; #use sort 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 Lice +nse or the GNU General Public License, which may be found in the Perl 5 source + kit. ); Benchmark::cmpthese(-1, { inline => q[ sort { $a cmp $b } @array; ], argless => q[ sort argless @array; ], proto => q[ sort proto @array; ], args => q[ sort { args($a, $b) } @array; ], }); __END__ P:\test>410266 Possible attempt to separate words with commas at P:\test\410266.pl li +n Name "main::b" used only once: possible typo at P:\test\410266.pl line Name "main::a" used only once: possible typo at P:\test\410266.pl line Useless use of sort in void context at (eval 4) line 1. ... Useless use of sort in void context at (eval 182) line 1. Rate argless proto inline args argless 6619798/s -- -2% -8% -19% proto 6748958/s 2% -- -6% -18% inline 7189879/s 9% 7% -- -12% args 8216252/s 24% 22% 14% --
|
|---|