EvolvingObjects
|
Registers a group of statistics, each statistic corresponding to user, system and wallclock times distribution. More...
#include <eoTimer.h>
Classes | |
struct | Stat |
Statistic related to a key (name). More... | |
Public Member Functions | |
void | start (const std::string &key) |
Starts a new measure for the given key. | |
void | stop (const std::string &key) |
Stops the mesure for the given key and saves the elapsed times. | |
std::map< std::string, Stat > & | stats () |
Getter for the statistics map. | |
Protected Attributes | |
std::map< std::string, Stat > | _stats |
std::map< std::string, eoTimer > | _timers |
Registers a group of statistics, each statistic corresponding to user, system and wallclock times distribution.
This class helps the user to measure time in different parts of an application. A name is associated to a statistic, on each call to start() and stop() for this name, a new number is added to the statistic, for each of the three measured times.
The statistics are only registered if the option "--parallelized-do-measure" is set to true, which can be checked thanks to global object eo::parallel.
This shows how the eoTimerStat can be used :
eoTimerStat timerStat; timerStat.start("first_point"); for( int i = 0; i < 1000; ++i ) { timerStat.start("single_computation"); single_computation( i ); timerStat.stop("single_computation"); } // After this loop, timerStat contains a statistic of key "single_computation" which contains 1000 measures for // each type of time. timerStat.stop("first_point"); // After this line, timerStat contains another statistic of key "first_point" which counted the duration of the // whole loop. int singleComputationUsertimeMean = 0; for( int i = 0; i < 1000; ++i ) { singleComputationUsertimeMean += timerStat.stats()["single_computation"].utime[i]; } std::cout << "Mean of user time spent in single computation: " << singleComputationUsertimeMean / 1000. << std::endl;
When using MPI, these statistics can be readily be serialized, so as to be sent over a network, for instance.
Implementation details: this eoTimerStat is in fact a map of strings (key) / Stat (value). Stat is an internal structure directly defined in the class, which contains three vectors modeling the distributions of the different types of elapsed times. Another map of strings (key) / eoTimer (value) allows to effectively retrieve the different times. The struct Stat will be exposed to client, which will use its members ; however, the client doesn't have anything to do directly with the timer, that's why the two maps are splitted.
void eoTimerStat::start | ( | const std::string & | key | ) | [inline] |
Starts a new measure for the given key.
This is only performed if parallel.doMeasure() is true, which is equivalent to the fact that parser found "--parallel-do-measure=1" in command line args.
key | The key of the statistic. |
Definition at line 263 of file eoTimer.h.
Referenced by eo::mpi::Job< void >::master(), eo::mpi::ProcessTaskParallelApply< EOT >::operator()(), and eo::mpi::Job< void >::worker().
void eoTimerStat::stop | ( | const std::string & | key | ) | [inline] |
Stops the mesure for the given key and saves the elapsed times.
Must follow a call of start with the same key.
This is only performed if parallel.doMeasure() is true, which is equivalent to the fact that parser found "--parallel-do-measure=1" in command line args.
key | The key of the statistic. |
Definition at line 281 of file eoTimer.h.
References eoTimer::systime(), eoTimer::usertime(), and eoTimer::wallclock().
Referenced by eo::mpi::Job< void >::master(), eo::mpi::ProcessTaskParallelApply< EOT >::operator()(), and eo::mpi::Job< void >::worker().