|
DP3
|
Very accurate timer for elapsed times. More...
#include <Timer.h>
Classes | |
| class | StartStop |
| Internal class to do an automatic start/stop. More... | |
Public Member Functions | |
| BaseTimer (const std::string &name=std::string()) | |
| double | getAverage () const |
| Get the average time (in seconds) between start/stop. More... | |
| uint64_t | getCount () const |
| Get the total number of times start/stop is done. More... | |
| double | getElapsed () const |
| Get the elapsed time (in seconds). More... | |
| BaseTimer & | operator+= (const BaseTimer &other) |
| Accumulate timer statistics. More... | |
| std::ostream & | print (std::ostream &str) const |
| Prints the timer. More... | |
| void | reset () |
| Resets the timer to zero. More... | |
| void | start () |
| Starts the timer. More... | |
| void | stop () |
| Stops the timer. More... | |
Very accurate timer for elapsed times.
Put timer.start() and timer.stop() calls around the piece of code to be timed; make sure that start() and stop() calls alternate. A timer can be started and stopped multiple times; both the average and total time, as well as the number of iterations are printed. The measured time is real time (as opposed to user or system time). The timer can be used to measure from 1 nanosecond to a century interval. The accuracy of the timer depends on the platform.
The internal RAII class StartStop can be used to do the start/stop. The constructor starts the timer, while the destructor stops it. It has the advantage that no explicit stop has to be given. Moreover, it makes the start/stop exception-safe.
| Clock | Clock type, which meets the Clock named requirements. This argument allows using a mocked clock. |
|
inlineexplicit |
Constructor.
| name | The name that will be used when printing the timer. |
|
inline |
Get the average time (in seconds) between start/stop.
|
inline |
Get the total number of times start/stop is done.
|
inline |
Get the elapsed time (in seconds).
|
inline |
Accumulate timer statistics.
|
inline |
Prints the timer.
|
inline |
Resets the timer to zero.
|
inline |
Starts the timer.
|
inline |
Stops the timer.