Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Not returning scalars(SV) to optimize and save memory?

by ikegami (Pope)
on Dec 06, 2007 at 20:19 UTC ( #655493=note: print w/replies, xml ) Need Help??

in reply to Not returning scalars(SV) to optimize and save memory?

Your influences are misleading you. The savings would be so minimal.... Let's put it to the test.
use strict; use warnings; use Benchmark qw( cmpthese ); use constant TRUE => 1 == 1; use constant FALSE => 1 == 0; sub old_foo { return 0; } sub new_foo { return; } cmpthese(-3, { old_foo => 'old_foo(); 1', new_foo => 'new_foo(); 1', }); sub old_bar { return 1; } sub new_bar { return TRUE; } cmpthese(-3, { old_bar => 'old_bar(); 1', new_bar => 'new_bar(); 1', });

The results fluctuated too much. Sometimes one is 20% faster than the other, sometimes it's the other way around. In other words, they are both so fast that the time they take is actually dependent on external factors.

By the way, new_foo isn't even equivalent to old_foo.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://655493]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2018-01-20 01:50 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (226 votes). Check out past polls.