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:$totalamount = 0; $companyname = "";
or:$totalamount = undef; $companyname = undef;
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 ?$totalamount = $companyname = undef;
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:if ((length($companyname)>0) && ($anotherstring eq 'DOIT')) { ... }
Any comments appreciated.if (($companyname) && ($anotherstring eq 'DOIT')) { ... }
In reply to How does variable definition affect Perl performance ? by EdsterTech
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |