Object for managing calls to the C-standard function gettimeofday(), calculating deltas and categorizing time spent according to a developer's wishes. Calls to gettimeofday() are precise to microseconds, and take considerably less time than that. With the option to lookup a section by numerical index, the timing can have no impact whatsoever on any serious computation, and even lookup by section name is relatively fast thanks to the findStringInVector() function. The relative time can be computed in a number of ways, so that the timer can be called less frequently but not accrue all of the time since it last sampled the computation.
More...
|
| StopWatch (const std::string &title_in=std::string("Timer")) |
| The basic constructor records the time at which initialization was called and creates a section called "Miscellaneous" to capture any times not assigned to a particular section.
|
|
| ~StopWatch ()=default |
| Default destructor.
|
|
double | getTimeAtStart () const |
| Get the time at which this StopWatch was first started.
|
|
double | getTimeAtLastTest () const |
| Get the time at which this StopWatch last recorded a test (this is not necessarily the last time this StopWatch fired off translateCurrentTime() which contains the actual call to the underlying gettimeofday(), as there are cases where one can simply query how long ago the StopWatch did anything).
|
|
double | getTimeSinceStart () const |
| Get the time since this StopWatch was first started.
|
|
double | getTimeSinceLastTest () const |
| Get the time since this StopWatch was last tested (see above for lengthier explanation).
|
|
std::string | getCategoryName (int query_index) const |
| Get the name of a timing category based on its index in the program.
|
|
int | getCategoryIndex (const std::string &query, ExceptionResponse policy=ExceptionResponse::DIE) const |
| Get the index of category based on its name. Returns -1 or an error if the named category is not present in the object.
|
|
double | getTotalDuration () const |
| Report the total duration recorded by this stopwatch under all sections.
|
|
int | addCategory (const std::string &name) |
| Add a section to the current StopWatch, if no such section already exists. Return the index of the section, whether newly added or not.
|
|
void | printResults (double precision=1.0e6) |
| Print the timings for this StopWatch.
|
|
|
| StopWatch (const StopWatch &original)=default |
| With no const members or points to repair, the default copy and move constructors, as well as copy and move assignment operators, will be applicable.
|
|
| StopWatch (StopWatch &&original)=default |
|
StopWatch & | operator= (const StopWatch &original)=default |
|
StopWatch & | operator= (StopWatch &&original)=default |
|
|
double | getCategoryDuration (int query_index) const |
| Get the duration recorded under any one category.
|
|
double | getCategoryDuration (const std::string &query_name) const |
|
|
double | getCategoryAverageInterval (int query_index) const |
| Get the average interval of time observed for any given category.
|
|
double | getCategoryAverageInterval (const std::string &query_name) const |
|
|
double | getCategoryMinimumTime (int query_index) const |
| Get the minimum stretch of time recorded under any one category.
|
|
double | getCategoryMinimumTime (const std::string &query_name) const |
|
|
double | getCategoryMaximumTime (int query_index) const |
| Get the maximum stretch of time recorded under any one category.
|
|
double | getCategoryMaximumTime (const std::string &query_name) const |
|
|
int | getCategorySamples (int query_index) const |
| Get the maximum stretch of time recorded under any one category.
|
|
int | getCategorySamples (const std::string &query_name) const |
|
|
void | assignTime (int target, double reference_time) |
| Assign an amount of time to this StopWatch.
|
|
void | assignTime (int target=0) |
|
void | assignTime (const std::string &target) |
|
void | assignTime (const std::string &target, double reference_time) |
|
|
double2 | timeDifferential (const std::string &catg_a, const std::string &catg_b, const std::string &referring_function=std::string("")) const |
| Obtain the time taken as the difference of two categories, catg_a - catg_b. The result is returned as the mean differential, which is exact, and an estimate of the standard deviation of the differential (based on the standard deviations of each category individually).
|
|
double2 | timeDifferential (int catg_a, int catg_b, const std::string &referring_function=std::string("")) const |
|
Object for managing calls to the C-standard function gettimeofday(), calculating deltas and categorizing time spent according to a developer's wishes. Calls to gettimeofday() are precise to microseconds, and take considerably less time than that. With the option to lookup a section by numerical index, the timing can have no impact whatsoever on any serious computation, and even lookup by section name is relatively fast thanks to the findStringInVector() function. The relative time can be computed in a number of ways, so that the timer can be called less frequently but not accrue all of the time since it last sampled the computation.