#!/usr/bin/perl
use warnings;
use strict;
use Benchmark;
timethese(1_000_000, {
'use_shift' => sub { sub_with_shift(0..2) },
'use_list' => sub { sub_with_list(0..2) },
'use_direct' => sub { sub_with_direct(0..2) },
});
sub sub_with_shift
{
my ($one, $two, $three) = (shift, shift, shift);
my $sum = $one+$two+$three;
}
sub sub_with_list
{
my ($one, $two, $three) = @_;
my $sum = $one+$two+$three;
}
sub sub_with_direct
{
my $sum = $_[0] + $_[1] + $_[2];
}
i think my example better reflects the core of the problem