From roberthpike at yahoo.com Fri Feb 2 12:31:39 2018 From: roberthpike at yahoo.com (Robert Pike) Date: Fri, 2 Feb 2018 20:31:39 +0000 (UTC) Subject: [kw-pm] Perl - optimizing code References: <1468006916.2291647.1517603499068.ref@mail.yahoo.com> Message-ID: <1468006916.2291647.1517603499068@mail.yahoo.com> Hi all,? ? ?I've been presented with the following code and I'm looking at ways of speeding it up (just this particular segment). A lot of data is running through this segment of code and placing a time print before and after it shows it takes approximately 4 minutes to complete. Any suggestions on how to speed up the processing of it? Some attempts have been made in the past from documentation and such found in the main script. I'm hoping to hear various opinions and ways different people might tackle different sections of the attached segment. Thanks in advance for suggestions.? Rob for ($sCurrLevel=0;$sCurrLevel<=$startLimit;$sCurrLevel++) {? ? ? ? @topLevel = split(/\~/, ${$aLevels}[$sCurrLevel]);? ? ? ? $topCnt = $#topLevel;? ? ? ? for ($tCnt=0;$tCnt<=$topCnt;$tCnt++) {? ? ? ? ? ? @detailLevel = split(/\,/, $topLevel[$tCnt]);? ? ? ? ? ? if ($sCurrLevel > 0) {? ? ? ? ? ? ? ? @lastLevel = split(/[\~,]/, ${$aLevels}[$sCurrLevel-1]);? ? ? ? ? ? ? ? $calcVal = $#{$drillDownMapping{$lastLevel[$tCnt]}};? ? ? ? ? ? ? ? for ($dcCnt=0;$dcCnt<=$#detailLevel;$dcCnt++) {? ? ? ? ? ? ? ? ? ? $detValue = $detailLevel[$dcCnt];? ? ? ? ? ? ? ? ? ? if ($lastLevel[$tCnt] ne "X" && $detValue ne "X") {? ? ? ? ? ? ? ? ? ? ? ? if ($matchLevel == -1) {? ? ? ? ? ? ? ? ? ? ? ? ? ? if (${$aQ}->param("drillOnID") eq $detValue) { $matchLevel = $sCurrLevel; }? ? ? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? ? ? $idMapping{$detValue} =? $lastLevel[$tCnt];? ? ? ? ? ? ? ? ? ? ? ? $calcVal += 1;? ? ? ? ? ? ? ? ? ? ? ? $drillDownMapping{$lastLevel[$tCnt]}[$calcVal] = $detValue;? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? undef (@lastLevel);? ? ? ? ? ? }? ? ? ? ? ? #---------------------------------? ? ? ? ? ? if ($#detailLevel <= 0) {? ? ? ? ? ? ? ? $currLevelList[$sCurrLevel][$tCnt][0] = $detailLevel[0];? ? ? ? ? ? } else {? ? ? ? ? ? ? ? push (@{$currLevelList[$sCurrLevel][$tCnt]}, @detailLevel);? ? ? ? ? ? }? ? ? ? ? ? undef(@detailLevel);? ? ? ? }? ? ? ? undef (@topLevel);? ? } -------------- next part -------------- An HTML attachment was scrubbed... URL: