note
ELISHEVA
<p>Small oversight - your benchmark with <c>$unused</c> never makes an assignment from <c>@_</c>. When I fixed the typo and reran it, <c>(undef, $x)= @_</c> was marginally faster than <c>($unused, $x) = @_</c> though not by an amount I consider significant (3%). -- Tested on Perl 5.10.0, system Perl for Debian Lenny, 32bit.</p>
<code>
use Benchmark qw(cmpthese);
my $a1='a'x1e6;
my $b1=12345;
cmpthese -1,{
a=>q[ sub{ my( undef, $x) = @_ }->( $a1, $b1 ) ],
b=>q[ sub{ my $x = $_[1] }->( $a1, $b1 ) ],
c=>q[ sub{ my( $unused, $x ) = @_;}->( $a1, $b1 ) ],
};
# Output
Rate c a b
c 649176/s -- -3% -33%
a 670690/s 3% -- -30%
b 963764/s 48% 44% --
</code>
<p><b>Update</b> added Perl version and platform; clarified ranking of results.</p>
895401
895454