Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^4: shift vs @_

by Anonymous Monk
on Oct 23, 2014 at 06:31 UTC ( [id://1104735]=note: print w/replies, xml ) Need Help??


in reply to Re^3: shift vs @_
in thread shift vs @_

#!/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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1104735]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-03-19 05:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found