in reply to Re^3: declaring lexical variables in shortest scope: performance?
in thread declaring lexical variables in shortest scope: performance?
I meant to say that comparing lexicals only: one with a my $z; inside the loop is so much slower. Even 35% is much
here is the code:
use Benchmark 'cmpthese'; cmpthese(-2, { predecl => ' my $y; my $x; for $x (1..10000) { $y+=$x } #print "$y\n"; ', lexical => ' my $y; for my $x (1..10000) { $y+=$x } #print "$y\n"; ', }); __END__
Rate predecl lexical predecl 1836/s -- -54% lexical 3996/s 118% --
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: declaring lexical variables in shortest scope: performance?
by LanX (Saint) on Mar 31, 2020 at 12:00 UTC | |
by bliako (Abbot) on Mar 31, 2020 at 12:14 UTC | |
by LanX (Saint) on Mar 31, 2020 at 12:31 UTC | |
by bliako (Abbot) on Mar 31, 2020 at 12:41 UTC | |
by Your Mother (Archbishop) on Mar 31, 2020 at 16:17 UTC | |
by LanX (Saint) on Mar 31, 2020 at 14:33 UTC |