Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^8: declaring lexical variables in shortest scope: performance?

by bliako (Monsignor)
on Mar 31, 2020 at 12:41 UTC ( [id://11114857]=note: print w/replies, xml ) Need Help??


in reply to Re^7: declaring lexical variables in shortest scope: performance?
in thread declaring lexical variables in shortest scope: performance?

got it, thanks.

use Benchmark 'cmpthese'; cmpthese(-2, { predecl => ' my $y; my $x; for $x (1..10000) { $y+=$x } ', lexical => ' my $y; for my $x (1..10000) { $y+=$x } ', aliased => ' my $y; for (1..10000) { $y+=$_ } ', });

Seems you are right!

Rate aliased lexical predecl aliased 3733/s -- -3% -5% lexical 3858/s 3% -- -2% predecl 3938/s 5% 2% --

Replies are listed 'Best First'.
Re^9: declaring lexical variables in shortest scope: performance?
by Your Mother (Archbishop) on Mar 31, 2020 at 16:17 UTC

    FWIW, I get what you get now and then and this or between just about as often–

    Rate predecl aliased lexical predecl 3106/s -- -0% -0% aliased 3121/s 0% -- 0% lexical 3121/s 0% 0% -- # This is perl 5, version 18, subversion 4 (v5.18.4) # built for darwin-thread-multi-2level
Re^9: declaring lexical variables in shortest scope: performance?
by LanX (Saint) on Mar 31, 2020 at 14:33 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-19 06:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found