Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Performance revision needed
by pfaut (Priest) on Jan 02, 2003 at 16:32 UTC | |
|
Re: Performance revision needed
by gjb (Vicar) on Jan 02, 2003 at 16:37 UTC | |
by Anonymous Monk on Jan 02, 2003 at 18:06 UTC | |
|
Re: Performance revision needed
by talexb (Chancellor) on Jan 02, 2003 at 16:47 UTC | |
|
Re: Performance revision needed
by rir (Vicar) on Jan 02, 2003 at 17:41 UTC | |
by Anonymous Monk on Jan 02, 2003 at 19:40 UTC | |
|
Re: Performance revision needed
by Thelonius (Priest) on Jan 02, 2003 at 18:45 UTC | |
|
Re: Performance revision needed
by Nitrox (Chaplain) on Jan 02, 2003 at 16:19 UTC | |
by IlyaM (Parson) on Jan 02, 2003 at 17:29 UTC | |
|
Re: Performance revision needed
by poj (Abbot) on Jan 02, 2003 at 19:33 UTC |