Progress timer for time and performance measurements.
The Timer class offers timing & benchmarking functionality for all kinds of applications. The following example code demonstrates the use of the WcTimer class, which combines the Timer class template with the WcPolicy for wall clock time measurements, for a single time measurement:
The timer class additionally offers the functionality to start several time measurements in order to evaluate minimal, maximal or average times. The next example demonstrates a possible setup for such a series of time measurements:
#include <Timer.h>
Public Types | |
using | TimingPolicy = TP |
Timing policy of the Timer. More... | |
Public Member Functions | |
Constructor | |
Timer () | |
Constructor of the Timer class. More... | |
Timer (uint_t counter, double min, double max, double total, double sumOfSquares) | |
Constructor of the Timer class. More... | |
Timing functions | |
void | start () |
Starting a single time measurement. More... | |
void | end () |
Ending a single time measurement. More... | |
void | reset () |
Resetting the timer. More... | |
Get functions | |
uint_t | getCounter () const |
Returns the total number of time measurements performed by this timer. More... | |
Time evaluation functions | |
double | total () const |
Returns the total elapsed time of all performed time measurements. More... | |
double | sumOfSquares () const |
Returns the sum of each (time measurement)^2. More... | |
double | average () const |
Returns the average time of all performed time measurements. More... | |
double | variance () const |
Returns the variance of all performed time measurements. More... | |
double | min () const |
Returns the minimal time of all performed time measurements. More... | |
double | max () const |
Returns the maximal time of all performed time measurements. More... | |
double | last () const |
Returns the last measured time. More... | |
Friends | |
template<typename T , typename G , typename TP2 > | |
mpi::GenericSendBuffer< T, G > & | operator<< (mpi::GenericSendBuffer< T, G > &buf, const Timer< TP2 > &t) |
template<typename T , typename TP2 > | |
mpi::GenericRecvBuffer< T > & | operator>> (mpi::GenericRecvBuffer< T > &buf, Timer< TP2 > &t) |
Related Functions | |
(Note that these are not member functions.) | |
template<typename TP > | |
void | to_json (nlohmann::json &j, const Timer< TP > &timer) |
Converts timer to json The signature is required by the json library. More... | |
Utility functions for Timers | |
uint_t | counter_ |
Number of performed time measurements. More... | |
double | start_ |
Start of the current time measurement. More... | |
double | end_ |
End of the current time measurement. More... | |
double | time_ |
The total elapsed time of all measurements. More... | |
double | sumOfSquares_ |
Sum of each (time measurement)^2. More... | |
double | min_ |
The minimal time of all measurements. More... | |
double | max_ |
The maximal time of all measurements. More... | |
double | last_ |
The last measured time. More... | |
void | merge (const Timer &other) |
Adds results of an other Timer to own results. More... | |
using walberla::timing::Timer< TP >::TimingPolicy = TP |
Timing policy of the Timer.
|
inlineexplicit |
|
inlineexplicit |
Constructor of the Timer class.
Initializes the timer with
_counter | number of timing measurements already done |
_min | the minimum time of the measurements |
_max | the maximum time of the measurements |
_total | the total time of all measurements |
_sumOfSquares | each measurement time squared, then summed |
|
inline |
Returns the average time of all performed time measurements.
|
inline |
Ending a single time measurement.
This function ends the currently running time measurement and performs the necessary statistical calculations.
|
inline |
Returns the total number of time measurements performed by this timer.
|
inline |
Returns the last measured time.
|
inline |
Returns the maximal time of all performed time measurements.
|
inline |
Adds results of an other Timer to own results.
|
inline |
Returns the minimal time of all performed time measurements.
|
inline |
Resetting the timer.
This function completely resets the timer and all information on the performed time measurements. In order to start a new time measurement, the start() function has to be used.
|
inline |
Starting a single time measurement.
This function starts a single time measurement.
|
inline |
Returns the sum of each (time measurement)^2.
Can be used to calculate the variance using the formula Var(x) = 1/N * ( E(x^2) - E(x)^2)
|
inline |
Returns the total elapsed time of all performed time measurements.
|
inline |
Returns the variance of all performed time measurements.
|
friend |
|
friend |
|
related |
Converts timer to json The signature is required by the json library.
|
private |
Number of performed time measurements.
|
private |
End of the current time measurement.
|
private |
The last measured time.
|
private |
The maximal time of all measurements.
|
private |
The minimal time of all measurements.
|
private |
Start of the current time measurement.
|
private |
Sum of each (time measurement)^2.
|
private |
The total elapsed time of all measurements.