in reply to Re: Is undef list assignment a no-op?
in thread Is undef list assignment a no-op?
Small oversight - your benchmark with $unused never makes an assignment from @_. When I fixed the typo and reran it, (undef, $x)= @_ was marginally faster than ($unused, $x) = @_ though not by an amount I consider significant (3%). -- Tested on Perl 5.10.0, system Perl for Debian Lenny, 32bit.
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% --
Update added Perl version and platform; clarified ranking of results.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Is undef list assignment a no-op?
by Tux (Canon) on Mar 25, 2011 at 12:58 UTC | |
Re^3: Is undef list assignment a no-op?
by BrowserUk (Patriarch) on Mar 25, 2011 at 14:56 UTC | |
by ELISHEVA (Prior) on Mar 25, 2011 at 15:34 UTC | |
by BrowserUk (Patriarch) on Mar 25, 2011 at 15:39 UTC | |
by repellent (Priest) on Mar 26, 2011 at 04:46 UTC | |
by Tux (Canon) on Mar 25, 2011 at 15:34 UTC | |
by BrowserUk (Patriarch) on Mar 25, 2011 at 15:38 UTC |
In Section
Seekers of Perl Wisdom