Code: Records per Second Tracking
Posted: Fri Feb 09, 2024 6:39 pm
I occasionally need to test/monitor throughput of TIs, especially when tuning parallel execution or debugging sluggish TI performance usually traced to one specific cube action. Below is code that I drop in the Prolog, Data, & Epilog tabs for limiting execution to the first N records, optionally writing message to log at checkpoints, and finally writing performance values to the log at completion.
Code: Select all
## Prolog ##
nCt = 0;
nMaxRecords = 50000;
nLogInterval = 10000;
nLogOut = 1;
## Data ##
IF(nCt = 0);
IF(nLogOut = 1);
LogOutput('WARN', 'starting data tab');
ENDIF;
nStart = NOW();
## stop execution if nMaxRecords reached
ELSEIF(nCt >= nMaxRecords);
ProcessBreak;
ENDIF;
IF(nLogInterval > 0);
IF(MOD(nCt, nLogInterval) = 0);
IF(nLogOut = 1);
sCt = NumberToStringEX(nCt, '#,###', '.', ',');
LogOutput('WARN', EXPAND('at record %sCt%'));
ENDIF;
ENDIF;
ENDIF;
nCt = nCt + 1;
## skip rest of Data tab; usefule for existing TI when just testing max throughput
## comment out ItemSkip and rerun to then see impact of Data tab actions on throughput
ItemSkip;
## Epilog ##
nDuration = (NOW() - nStart) * 86400;
nRecSec = nCt \ nDuration;
sDuration = NumberToStringEX(nDuration, '#,###', '.', ',');
sRecSec = NumberToStringEX(nRecSec, '#,###', '.', ',');
sCt = NumberToStringEX(nCt, '#,###', '.', ',');
LogOutput('WARN', EXPAND('Duration:%sDuration% seconds; Records:%sCt%; RecordsPerSecond:%sRecSec%'));