Perl optimisation help

Peter plp-ysDPMY98cNQDDBjDh4tngg at public.gmane.org
Fri Jun 9 08:45:19 UTC 2006


Thanks to all who have responded. I did not have time to check the 
perlmonger links suggested, but I think I have solved my problem. 
Conclusions:

Solutions by speed:

   5. $var .= $line;
  13. %hash{$idx++} = $line; later collect this into $var using .= or join
180. $var = $var.$line;
n/a. @var = (@var, $line);

The first number is seconds runtime with my test dataset (8Megs). In all 
cases there is a 'collect' phase and a 'print' phase. The 'collect' 
phase has the $var .= $line; run in a certain phase of a state machine 
that analyzes <INPUT> lines. It can collect up to 100,000 lines of about 
80 characters (~8Megs). In all cases the modified collect instructions 
were placed in the exact same place in the code, and no loop rewriting 
was done. It can be said that there is some distance (code length 
speaking) between the calls to the collect statements.

thanks again,

Peter
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list