diff --git a/alib2common/src/measurements/MeasurementFrame.cpp b/alib2common/src/measurements/MeasurementFrame.cpp index d78f5646baf3dafe9165afd493fa420904b9d7df..b79de7a4e44bd3af937dc285f5e71d5ac22dc343 100644 --- a/alib2common/src/measurements/MeasurementFrame.cpp +++ b/alib2common/src/measurements/MeasurementFrame.cpp @@ -20,4 +20,16 @@ std::ostream & operator <<( std::ostream & os, const MeasurementFrame & frame ) return os; } +MeasurementFrame MeasurementFrame::aggregate ( const std::vector < MeasurementFrame > & framesToAggregate ) { + MeasurementFrame aggregatedFrame ( framesToAggregate[0].name, framesToAggregate[0].type, framesToAggregate[0].parent_idx ); + + aggregatedFrame.sub_idxs = framesToAggregate[0].sub_idxs; + + aggregatedFrame.time = TimeDataFrame::aggregate ( framesToAggregate ); + aggregatedFrame.memory = MemoryDataFrame::aggregate ( framesToAggregate ); + aggregatedFrame.counter = CounterDataFrame::aggregate ( framesToAggregate ); + + return aggregatedFrame; +} + } diff --git a/alib2common/src/measurements/MeasurementFrame.hpp b/alib2common/src/measurements/MeasurementFrame.hpp index 79b88520887e93c5c108acede5f60e74831d248b..5998f89403a7a4d161d0c89512c518433b71e409 100644 --- a/alib2common/src/measurements/MeasurementFrame.hpp +++ b/alib2common/src/measurements/MeasurementFrame.hpp @@ -28,6 +28,8 @@ struct MeasurementFrame { CounterDataFrame counter; MeasurementFrame ( measurements::stealth_string, measurements::Type, unsigned ); + + static MeasurementFrame aggregate ( const std::vector < MeasurementFrame > & ); }; std::ostream & operator <<( std::ostream &, const MeasurementFrame & ); diff --git a/alib2common/src/measurements/MeasurementResults.cpp b/alib2common/src/measurements/MeasurementResults.cpp index ae5ad56ae0b548edd2f0314b9cc902fa071629fa..df4444896dca262a0d17edf4b85d65b858d91440 100644 --- a/alib2common/src/measurements/MeasurementResults.cpp +++ b/alib2common/src/measurements/MeasurementResults.cpp @@ -97,6 +97,23 @@ void MeasurementResults::print_as_tree ( std::ostream & os, unsigned idx, std::s } } +MeasurementResults MeasurementResults::aggregate ( const std::vector < MeasurementResults > & resultsToAggregate ) { + MeasurementResults aggregatedResults; + + size_t frameCount = resultsToAggregate[0].frames.size ( ); + + for ( size_t frameIdx = 0; frameIdx < frameCount; ++frameIdx ) { + std::vector < MeasurementFrame > framesToAggregate; + + for ( const MeasurementResults & measurementResults : resultsToAggregate ) + framesToAggregate.push_back ( measurementResults.frames[frameIdx] ); + + aggregatedResults.frames.push_back ( MeasurementFrame::aggregate ( framesToAggregate ) ); + } + + return aggregatedResults; +} + const int MeasurementXalloc::FORMAT = std::ios::xalloc ( ); std::ostream & operator <<( std::ostream & os, const MeasurementResults & mr ) { diff --git a/alib2common/src/measurements/MeasurementResults.hpp b/alib2common/src/measurements/MeasurementResults.hpp index 618834b24db73a523147b24052a4a945c54be325..62a4088b0392b34e13e33e369bbe1c8695ac8ef8 100644 --- a/alib2common/src/measurements/MeasurementResults.hpp +++ b/alib2common/src/measurements/MeasurementResults.hpp @@ -29,6 +29,8 @@ struct MeasurementResults { void print_as_list ( std::ostream & ) const; void print_as_tree ( std::ostream & ) const; + static MeasurementResults aggregate ( const std::vector < MeasurementResults > & ); + private: void print_as_list ( std::ostream &, unsigned ) const; void print_as_tree ( std::ostream &, unsigned, std::string &, bool ) const; diff --git a/alib2common/src/measurements/frames/CounterDataFrame.cpp b/alib2common/src/measurements/frames/CounterDataFrame.cpp index 4541f95b22ccdb4cf36c77c44104d4bf2793c265..e148a8c90d4dd46d9d2316fff89c62d36cb2a412 100644 --- a/alib2common/src/measurements/frames/CounterDataFrame.cpp +++ b/alib2common/src/measurements/frames/CounterDataFrame.cpp @@ -47,6 +47,11 @@ void CounterDataFrame::hint ( unsigned frame_idx, measurements::stealth_vector < } } +CounterDataFrame CounterDataFrame::aggregate ( const std::vector < MeasurementFrame > & framesToAggregate ) { + // dummmy aggregation + return framesToAggregate[0].counter; +} + std::ostream & operator <<( std::ostream & os, const CounterDataFrame & cdf ) { os << "cnts: ("; diff --git a/alib2common/src/measurements/frames/CounterDataFrame.hpp b/alib2common/src/measurements/frames/CounterDataFrame.hpp index 287930a2998375a13d92fc6806c592618a262a4c..10896db9c94b874b356ceae61a0acb594328a60e 100644 --- a/alib2common/src/measurements/frames/CounterDataFrame.hpp +++ b/alib2common/src/measurements/frames/CounterDataFrame.hpp @@ -33,6 +33,8 @@ struct CounterDataFrame { static void init ( unsigned, measurements::stealth_vector < MeasurementFrame > & ); static void update ( unsigned, measurements::stealth_vector < MeasurementFrame > & ); static void hint ( unsigned, measurements::stealth_vector < MeasurementFrame > &, CounterHint ); + + static CounterDataFrame aggregate ( const std::vector < MeasurementFrame > & ); }; std::ostream & operator <<( std::ostream &, const CounterDataFrame & ); diff --git a/alib2common/src/measurements/frames/MemoryDataFrame.cpp b/alib2common/src/measurements/frames/MemoryDataFrame.cpp index dd1bd8cb1041b1ed6ebe4cf4c4beed77e854e306..302b872b12245aec4b78bcbb3549389f0b889761 100644 --- a/alib2common/src/measurements/frames/MemoryDataFrame.cpp +++ b/alib2common/src/measurements/frames/MemoryDataFrame.cpp @@ -64,6 +64,11 @@ void MemoryDataFrame::hint ( unsigned frame_idx, measurements::stealth_vector < } } +MemoryDataFrame MemoryDataFrame::aggregate ( const std::vector < MeasurementFrame > & framesToAggregate ) { + // dummmy aggregation + return framesToAggregate[0].memory; +} + std::ostream & operator <<( std::ostream & os, const MemoryDataFrame & mdf ) { os << mdf.start_heap_usage << "B shu, " << mdf.end_heap_usage << "B ehu, " << mdf.high_watermark << "B hw, " << mdf.in_frame_high_watermark << "B if_hw"; return os; diff --git a/alib2common/src/measurements/frames/MemoryDataFrame.hpp b/alib2common/src/measurements/frames/MemoryDataFrame.hpp index 4fdb5eec03128d5d9991946951e68e4c6128192a..f0a4672491d5652808c081464bcf6f3775cdfe61 100644 --- a/alib2common/src/measurements/frames/MemoryDataFrame.hpp +++ b/alib2common/src/measurements/frames/MemoryDataFrame.hpp @@ -21,7 +21,7 @@ struct MemoryHint { NEW, DELETE }; - Type type; + Type type; value_type size; }; @@ -39,6 +39,8 @@ struct MemoryDataFrame { static void init ( unsigned, measurements::stealth_vector < MeasurementFrame > & ); static void update ( unsigned, measurements::stealth_vector < MeasurementFrame > & ); static void hint ( unsigned, measurements::stealth_vector < MeasurementFrame > &, MemoryHint ); + + static MemoryDataFrame aggregate ( const std::vector < MeasurementFrame > & ); }; std::ostream & operator <<( std::ostream &, const MemoryDataFrame & ); diff --git a/alib2common/src/measurements/frames/TimeDataFrame.cpp b/alib2common/src/measurements/frames/TimeDataFrame.cpp index c641a5f2a182b0b6fbd33cc7d67233251d9ce1b7..43f5f1c8bb0ccbe04fea3c072b85732c46722401 100644 --- a/alib2common/src/measurements/frames/TimeDataFrame.cpp +++ b/alib2common/src/measurements/frames/TimeDataFrame.cpp @@ -4,6 +4,7 @@ #include <sstream> #include "../MeasurementFrame.hpp" +#include <iostream> using namespace std::chrono; @@ -26,6 +27,20 @@ void TimeDataFrame::update ( unsigned frame_idx, measurements::stealth_vector < parent_frame.time.in_frame_duration -= current_frame.time.duration; } +TimeDataFrame TimeDataFrame::aggregate ( const std::vector < MeasurementFrame > & framesToAggregate ) { + TimeDataFrame aggregatedTimeDataFrame { }; + + for ( const MeasurementFrame & frame : framesToAggregate ) { + aggregatedTimeDataFrame.duration += frame.time.duration; + aggregatedTimeDataFrame.in_frame_duration += frame.time.in_frame_duration; + } + + aggregatedTimeDataFrame.duration /= framesToAggregate.size ( ); + aggregatedTimeDataFrame.in_frame_duration /= framesToAggregate.size ( ); + + return aggregatedTimeDataFrame; +} + std::ostream & operator <<( std::ostream & os, const TimeDataFrame & tdf ) { os << tdf.duration << " dur, " << tdf.in_frame_duration << " if_dur"; return os; diff --git a/alib2common/src/measurements/frames/TimeDataFrame.hpp b/alib2common/src/measurements/frames/TimeDataFrame.hpp index efb0664ab34790f81f385ad2a344950982eb2fa9..99e7f5a09bd880385e99801a01b782eb4c6fb208 100644 --- a/alib2common/src/measurements/frames/TimeDataFrame.hpp +++ b/alib2common/src/measurements/frames/TimeDataFrame.hpp @@ -24,6 +24,8 @@ struct TimeDataFrame { static void init ( unsigned, measurements::stealth_vector < MeasurementFrame > & ); static void update ( unsigned, measurements::stealth_vector < MeasurementFrame > & ); + + static TimeDataFrame aggregate ( const std::vector < MeasurementFrame > & ); }; std::ostream & operator <<( std::ostream &, const std::chrono::microseconds & ); diff --git a/alib2measurepp/src/provisioner/MeasurementProvisioner.cpp b/alib2measurepp/src/provisioner/MeasurementProvisioner.cpp index bd3723379a7824951f865092ac29e542717fbb2e..74c36f510bf9c2ec65c0dcf275ed48860f3efb39 100644 --- a/alib2measurepp/src/provisioner/MeasurementProvisioner.cpp +++ b/alib2measurepp/src/provisioner/MeasurementProvisioner.cpp @@ -96,7 +96,7 @@ MPRPipelineResults MeasurementProvisioner::runPipeline ( const MPPipeline & pipe ofdstream ofdlog ( pre.stderrFd ); - vector < vector < MeasurementResults > > pipelineMeasurementSubResults; + vector < vector < MeasurementResults > > commandMeasurementSubResults; MPRPipelineResults pipelineFinalResults { }; @@ -138,20 +138,24 @@ MPRPipelineResults MeasurementProvisioner::runPipeline ( const MPPipeline & pipe if ( pipelineFinalResults.pipelineStatus.exitCode != 0 ) break; - pipelineMeasurementSubResults.push_back ( std::move ( pipelineMeasurementResults ) ); + commandMeasurementSubResults.push_back ( std::move ( pipelineMeasurementResults ) ); } // if everything went smoothly, we aggregate the results if ( pipelineFinalResults.pipelineStatus.exitCode == 0 ) { - // FIXME we need proper aggregation - vector < MeasurementResults > aggregatedMeasurementResults = pipelineMeasurementSubResults[0]; + // FIXME we need proper aggregation - vector < MeasurementResults >::iterator amrIter = aggregatedMeasurementResults.begin ( ); + vector < vector < MeasurementResults > > transposedCommandMeasurementSubResults ( pipeline.size ( ) ); + + for ( vector < MeasurementResults > & commandResults : commandMeasurementSubResults ) + for ( size_t i = 0; i < commandResults.size ( ); ++i ) + transposedCommandMeasurementSubResults[i].push_back ( std::move ( commandResults[i] ) ); + + vector < vector < MeasurementResults > >::iterator tcmsIter = transposedCommandMeasurementSubResults.begin ( ); MPPipeline::const_iterator mppcIter = pipeline.cbegin ( ); - for ( ; mppcIter != pipeline.cend ( ); ++mppcIter, ++amrIter ) { - pipelineFinalResults.commandResults.push_back ( { mppcIter->getRawCommand ( ), std::move ( * amrIter ) } ); - } + for ( ; mppcIter != pipeline.cend ( ); ++mppcIter, ++tcmsIter ) + pipelineFinalResults.commandResults.push_back ( { mppcIter->getRawCommand ( ), MeasurementResults::aggregate ( * tcmsIter ) } ); ofdlog << "| \tpipeline: \tOK" << endl; } else { diff --git a/alib2measurepp/src/provisioner/MeasurementProvisioner.hpp b/alib2measurepp/src/provisioner/MeasurementProvisioner.hpp index 98beda6659cb833c21bf2df1f418b7e0cfbf8a0a..2ef9a155526ad72064aa003c3b380b3bd45e4b5a 100644 --- a/alib2measurepp/src/provisioner/MeasurementProvisioner.hpp +++ b/alib2measurepp/src/provisioner/MeasurementProvisioner.hpp @@ -21,32 +21,27 @@ class MeasurementProvisioner { static void prepareEnvironment ( const MeasurementProvisionerConfiguration & ); static MPRPipelineResults runPipeline ( const MPPipeline &, const MPSubstitutionMap &, const MeasurementProvisionerConfiguration & ); - - struct PipelineRunnerEnvironment { MPUtils::ShmFileHandle measurementsTmpfile, inputTmpfile, outputTmpfile, errorTmpfile; int measurementsFd, stdinFd, stdoutFd, stderrFd; public: + PipelineRunnerEnvironment ( ); + ~PipelineRunnerEnvironment ( ); - PipelineRunnerEnvironment(); - ~PipelineRunnerEnvironment(); - - void commandFdInit(); - void commandFdSwap(); - void commandFdEnd(); + void commandFdInit ( ); + void commandFdSwap ( ); + void commandFdEnd ( ); - std::string retrievePipelineError(); - MeasurementResults retrieveMeasurementResults(); + std::string retrievePipelineError ( ); + MeasurementResults retrieveMeasurementResults ( ); }; public: static MeasurementProvisionerResults runConfiguration ( const MeasurementProvisionerConfiguration & ); }; - - } #endif /* MEASUREMENT_PROVISIONER_HPP_ */