I have created a script that manipulates text files around 80 meg in size (1.5 million lines approximately), and the following block of code seems to be a bottleneck. The current code takes around 19 minutes to execute on a sun box with a single 450 mhz processor (64 bit)
Any suggestions for improving performance?while (<SSLOG>) { chomp (($date,$atime,$etime,$mth,$port,$attrID,$value)=split(/;/,$ +_)); # Convert the log time to UTC time ($HH, $MM, $SS)=split(/:/,$etime); ($year, $month, $day) = $date =~ m/^(.{4})(.{2})(.*)/; $month -= 1; $Time = timelocal($SS, $MM, $HH, $day, $month, $year); # Collect non-zero data if ($Conf[7] =~ /NO/i) { if ($value != /^0/) { # Build a hash of MTypeHandles with their unique ports $Hash{$mth}{$port}++; my @entry = (); $attrID =~ s/\s*//g; $port =~ s/\s*//g; if ($port =~ /\-/) { $port =~ s/\-//; } $key = $attrID; $val = $DS_Info{$key}; $val = join("", $val, $port); @entry = ($Time, $mth, $val, $value); # Populate the data array push @Data, [@entry]; } } # Collect zero data elsif($Conf[7] =~ /YES/i) { # Build a hash of MTypeHandles with their unique ports $Hash{$mth}{$port}++; my @entry = (); $attrID =~ s/\s*//g; $port =~ s/\s*//g; if ($port =~ /\-/) { $port =~ s/\-//; } $key = $attrID; $val = $DS_Info{$key}; $val = join("", $val, $port); @entry = ($Time, $mth, $val, $value); # Populate the data array push @Data, [@entry]; } }
Thanks
In reply to Performance revision needed by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |