On 2012-05-21 13:40, sono...@fannullone.us wrote:
On May 20, 2012, at 10:07 PM, David Christensen wrote:

I've updated function_arguments.pl with Benchmark, below. f_direct() is the 
fastest, f_shift() is in the middle (12% slower), and f_assign() is the slowest 
(37%).

David,

        Are you saying that it would be faster to do:

my $this_date = shift;
my $output = shift;

        as opposed to:

my ($this_date, $output) = @_;

        or am I not reading your assessment correctly?

Some tests:

          Rate shift  copy
shift 504541/s    --   -8%
copy  549451/s    9%    --

          Rate shift  copy
shift 559284/s    --   -6%
copy  592417/s    6%    --

The test code:

#!/usr/bin/perl

use warnings;
use strict;

use Benchmark qw(:all);

cmpthese ( 5000000, {
                'copy'  => 'my @args = qw(a b c); copy(@args)',
                'shift' => 'my @args = qw(a b c); shift_off(@args);',
        });

sub shift_off {
    my $x = shift;
    my $y = shift;
    my $z = shift;
}
sub copy {
    my ( $x, $y, $z ) = @_;
}

Steve

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to