No such thing as a small change | |
PerlMonks |
How does variable definition affect Perl performance ?by EdsterTech (Initiate) |
on Dec 04, 2009 at 22:46 UTC ( [id://811173]=perlquestion: print w/replies, xml ) | Need Help?? |
EdsterTech has asked for the wisdom of the Perl Monks concerning the following question:
I've been asked to add a function to a huge script that currently takes an age to run.
Note that I haven't been asked to look at performance (and a lot of the blame is on the large amount of data that it has to trawl through), but the Christmas period is usually a bit quiet and I think that a bit of fiddling might improve it, and am looking for confirmation (or warnings to the contrary!). Firstly, the script initialises about 100 variables once in a while using the following style of declaration: When I look at it, it looks wrong - I want to change them to: or: Is this likely to improve performance, or does "pre-loading/maintaining" the variable type (integer/string) have some kind of use that I've been ignorant of for the past n years ? Secondly, the script tests whether string variables are populated by using the length function, which seems a pointless way of slowing the script - e.g. This is what I would have done: Any comments appreciated. Ed
Back to
Seekers of Perl Wisdom
|
|