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

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

by bliako (Parson)
on Mar 31, 2020 at 12:41 UTC ( #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 (Bishop) 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 (Cardinal) on Mar 31, 2020 at 14:33 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2020-07-08 14:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?