this leads to following timings:while (chomp ($line = <$gsr>)) { my @l1; @l1 = split $tab, $line; @l1 = split $tab, $line; @l1 = split $tab, $line; print(join($tab,@l1[@okc])); print(join($tab,@l1[@okc])); print(join($tab,@l1[@okc])); }
i.e. the 2nd and following assignments seem to take more time than the 1st one. Could that be attributed to some additional overhead? It doesn't happen when omitting the "my" declaration or using "our" instead (see below). This is consistent across runs. If introducing "my" in the middle of a block the effect is the same (see at bottom). Using "local" instead of "my" seems not as expensive. But both "my" and "local" seem to slow down last write operation (is that some artifact? All measurments taken on Windows 7 with outpout redirected to a file).73µs my@l1; 1.71s @l1 = split $tab, $line; 2.40s @l1 = split $tab, $line; 2.33s @l1 = split $tab, $line; 805ms print(join($tab,@l1[@okc])); 798ms print(join($tab,@l1[@okc])); 1.66s print(join($tab,@l1[@okc]));
235µs local @l1; 1.18s @l1 = split $tab, $line; 1.79s @l1 = split $tab, $line; 1.78s @l1 = split $tab, $line; 824ms print(join($tab,@l1[@okc])); 806ms print(join($tab,@l1[@okc])); 1.61s print(join($tab,@l1[@okc])); 92µs our @l1; 1.77s @l1 = split $tab, $line; 1.77s @l1 = split $tab, $line; 1.77s @l1 = split $tab, $line; 829ms print(join($tab,@l1[@okc])); 820ms print(join($tab,@l1[@okc])); 1.03s print(join($tab,@l1[@okc])); #my @l1; 1.78s @l1 = split $tab, $line; 1.77s @l1 = split $tab, $line; 1.77s @l1 = split $tab, $line; 810ms print(join($tab,@l1[@okc])); 805ms print(join($tab,@l1[@okc])); 1.01s print(join($tab,@l1[@okc])); 1.80s @l1 = split $tab, $line; 1.70s my @l1 = split $tab, $line; 2.41s @l1 = split $tab, $line; 807ms print(join($tab,@l1[@okc])); 794ms print(join($tab,@l1[@okc])); 1.65s print(join($tab,@l1[@okc]));
In reply to "my" slowing down programs? by jf1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |