Beefy Boxes and Bandwidth Generously Provided by pair Networks Russ
The stupid question is the question not asked
 
PerlMonks  

Re: Ampersands and sub speed

by chromatic (Archbishop)
on Oct 14, 2005 at 18:43 UTC ( [id://500395]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Ampersands and sub speed

It would surprise me if this were significant. You're not calling empty subroutines, so the time spent within the subroutines is likely more significant than the time spent calling the subroutines.

Even in those cases where the speed is significant, I wonder if, should it ever happen that you need to manipulate @_ before calling a function, the overhead of managing the array (actually the stack) dwarfs the gains of avoiding the stack manipulations.

Replies are listed 'Best First'.
Re^2: Ampersands and sub speed
by creamygoodness (Curate) on Oct 14, 2005 at 19:01 UTC
    Since it turns out to be stack manipulation providing the savings, the cases where I'm going to be able to take advantage of the ampersand are few and far between.

    cmpthese( -1, { k1 => sub { $foo->do_nothing(1) }, k2 => sub { Foo->do_nothing(1) }, k3 => sub { Foo::do_nothing(1) }, k4 => sub { do_nothing(1) }, k5 => sub { &do_nothing(1) }, });
    Rate k2 k1 k5 k3 k4 k2 1380806/s -- -14% -34% -35% -37% k1 1610612/s 17% -- -23% -25% -26% k5 2103412/s 52% 31% -- -1% -4% k3 2133262/s 54% 32% 1% -- -2% k4 2181254/s 58% 35% 4% 2% --
    --
    Marvin Humphrey
    Rectangular Research ― http://www.rectangular.com

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://500395]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.