#include <lemon/time_measure.h>
Inherited by TimeReport.
Inheritance diagram for Timer:
include<lemon/time_measure.h> include<iostream> int main() { ... Timer T; doSomething(); std::cout << T << '\n'; T.restart(); doSomethingElse(); std::cout << T << '\n'; ... }
The Timer can also be stopped and started again, so it is possible to compute collected running times.
Public Member Functions | |
Timer (bool run=true) | |
Constructor. | |
Control the state of the timer | |
Basically a Timer can be either running or stopped, but it provides a bit finer control on the execution. The Timer also counts the number of start() executions, and is stops only after the same amount (or more) stop()s. This can be useful e.g. to compute the running time of recursive functions. | |
void | reset () |
Reset and stop the time counters. | |
void | start () |
Start the time counters. | |
void | stop () |
Stop the time counters. | |
void | halt () |
Halt (i.e stop immediately) the time counters. | |
int | running () |
Returns the running state of the timer. | |
void | restart () |
Restart the time counters. | |
Query Functions for the ellapsed time | |
double | userTime () const |
Gives back the ellapsed user time of the process. | |
double | systemTime () const |
Gives back the ellapsed system time of the process. | |
double | cUserTime () const |
Gives back the ellapsed user time of the process' children. | |
double | cSystemTime () const |
Gives back the ellapsed user time of the process' children. | |
double | realTime () const |
Gives back the ellapsed real time. | |
operator TimeStamp () const | |
Computes the ellapsed time. |
|
|
|
This function resets and stops the time counters
|
|
This function starts the time counters. If the timer is started more than ones, it will remain running until the same amount of stop() is called.
|
|
This function stops the time counters. If start() was executed more than once, then the same number of stop() execution is necessary the really stop the timer.
|
|
This function stops immediately the time counters.
|
|
This function returns the number of stop() exections that is necessary to really stop the timer. For example the timer is running if and only if the return value is |
|
This function is a shorthand for a reset() and a start() calls. |
|
This conversion computes the ellapsed time, therefore you can print the ellapsed time like this. Timer T; doSomething(); std::cout << T << '\n'; |