From b2e7f91754382755f05ec4d023330b9b6bebfa49 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Mon, 18 Aug 2025 18:22:17 +0200 Subject: [PATCH] Clamp the records to time range for text export Fixes: https://github.com/bsc-performance-tools/wxparaver/issues/26 --- api/textoutput.cpp | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/api/textoutput.cpp b/api/textoutput.cpp index 2abc1cd..31c3521 100644 --- a/api/textoutput.cpp +++ b/api/textoutput.cpp @@ -120,17 +120,26 @@ void TextOutput::dumpWindow( Timeline *whichWindow, string& strOutputFile, Progr outputFile << LabelConstructor::objectLabel( i, whichWindow->getLevel(), trace, false, false ) << "\t"; } + TRecordTime t0 = whichWindow->getBeginTime( i ); + TRecordTime t1 = whichWindow->getEndTime( i ); + + // Clamp the time range + if ( t0 < beginTime ) + t0 = beginTime; + if ( t1 > endTime ) + t1 = endTime; + + TRecordTime dt = t1 - t0; + if( windowTimeUnits ) { - outputFile << whichWindow->traceUnitsToWindowUnits( - whichWindow->getBeginTime( i ) ) << "\t"; - outputFile << whichWindow->traceUnitsToWindowUnits( - whichWindow->getEndTime( i ) - whichWindow->getBeginTime( i ) ) << "\t"; + outputFile << whichWindow->traceUnitsToWindowUnits( t0 ) << "\t"; + outputFile << whichWindow->traceUnitsToWindowUnits( dt ) << "\t"; } else { - outputFile << (PRV_UINT64)whichWindow->getBeginTime( i ) << "\t"; - outputFile << (PRV_UINT64)( whichWindow->getEndTime( i ) - whichWindow->getBeginTime( i ) ) << "\t"; + outputFile << (PRV_UINT64) t0 << "\t"; + outputFile << (PRV_UINT64) dt << "\t"; } if( textualSemantic ) @@ -145,17 +154,27 @@ void TextOutput::dumpWindow( Timeline *whichWindow, string& strOutputFile, Progr { outputFile << LabelConstructor::objectLabel( i, whichWindow->getLevel(), trace, false, false ) << "\t"; } + + TRecordTime t0 = whichWindow->getBeginTime( i ); + TRecordTime t1 = whichWindow->getEndTime( i ); + + // Clamp the time range + if ( t0 < beginTime ) + t0 = beginTime; + if ( t1 > endTime ) + t1 = endTime; + + TRecordTime dt = t1 - t0; + if( windowTimeUnits ) { - outputFile << whichWindow->traceUnitsToWindowUnits( - whichWindow->getBeginTime( i ) ) << "\t"; - outputFile << whichWindow->traceUnitsToWindowUnits( - whichWindow->getEndTime( i ) - whichWindow->getBeginTime( i ) ) << "\t"; + outputFile << whichWindow->traceUnitsToWindowUnits( t0 ) << "\t"; + outputFile << whichWindow->traceUnitsToWindowUnits( dt ) << "\t"; } else { - outputFile << (PRV_UINT64)whichWindow->getBeginTime( i ) << "\t"; - outputFile << (PRV_UINT64)( whichWindow->getEndTime( i ) - whichWindow->getBeginTime( i ) ) << "\t"; + outputFile << (PRV_UINT64) t0 << "\t"; + outputFile << (PRV_UINT64) dt << "\t"; } if( textualSemantic )