Hello monks,

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)

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]; } }
Any suggestions for improving performance?

Thanks


In reply to Performance revision needed by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.