#! perl -slw use strict; use Benchmark qw[cmpthese]; use constant ARG1 => 0; use constant ARG2 => 1; use constant LAST => -1; sub directly{ return "$_[ARG1] - $_[ARG2]" if $_[LAST]; } sub shifty{ my ($arg1, $arg2, $arg3) = (shift, shift, shift); return "$arg1 - $arg2" if $arg3; } sub listy{ my ($arg1, $arg2, @others) = @_; return "$arg1 - $arg2" if $others[-1]; } sub listya{ my (@args) = @_; return "$args[1] - $args[1]" if $args[-1]; } our @a100 = 1..100; cmpthese( -3, { directly3 => 'directly 1, "TWO", 3.0;', directly100 => 'directly @a100;', shifty3 => 'shifty 1, "TWO", 3.0;', shifty100 => 'shifty @a100;', listy3 => 'listy 1, "TWO", 3.0;', listya => 'listya 1, "TWO", 3.0', listya100 => 'listya @a100;', }); __END__ Name "main::a100" used only once: possible typo at C:\test\233863.pl line 14. Benchmark: running directly100, directly3, listy3, listya, listya100, shifty100, shifty3 , each for at least 3 CPU seconds directly100: 5 wallclock secs ( 3.19 usr + 0.00 sys = 3.19 CPU) @ 27542.27/s (n=87970) directly3: 1 wallclock secs ( 3.03 usr + 0.00 sys = 3.03 CPU) @ 47871.13/s (n=145241) listy3: 4 wallclock secs ( 3.10 usr + 0.00 sys = 3.10 CPU) @ 19624.88/s (n=60896) listya: 4 wallclock secs ( 3.04 usr + 0.00 sys = 3.04 CPU) @ 19505.42/s (n=59394) listya100: 3 wallclock secs ( 3.12 usr + 0.00 sys = 3.12 CPU) @ 3179.52/s (n=9936) shifty100: 4 wallclock secs ( 3.04 usr + 0.00 sys = 3.04 CPU) @ 21964.84/s (n=66839) shifty3: 5 wallclock secs ( 3.09 usr + 0.00 sys = 3.09 CPU) @ 30639.55/s (n=94523) Rate listya100 listya listy3 shifty100 directly100 shifty3 directly3 listya100 3180/s -- -84% -84% -86% -88% -90% -93% listya 19505/s 513% -- -1% -11% -29% -36% -59% listy3 19625/s 517% 1% -- -11% -29% -36% -59% shifty100 21965/s 591% 13% 12% -- -20% -28% -54% directly100 27542/s 766% 41% 40% 25% -- -10% -42% shifty3 30640/s 864% 57% 56% 39% 11% -- -36% directly3 47871/s 1406% 145% 144% 118% 74% 56% --