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 | |
|
Re^9: declaring lexical variables in shortest scope: performance?
by LanX (Saint) on Mar 31, 2020 at 14:33 UTC |