Class for measuring the cpu time and real time usage of the process. It is quite easy-to-use, here is a short example.
* #include<lemon/time_measure.h>
* #include<iostream>
*
* int main()
* {
*
* ...
*
* 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.
- Warning
- Depending on the operation system and its actual configuration the time counters have a certain (10ms on a typical Linux system) granularity. Therefore this tool is not appropriate to measure very short times. Also, if you start and stop the timer very frequently, it could lead to distorted results.
- Note
- If you want to measure the running time of the execution of a certain function, consider the usage of TimeReport instead.
- See Also
- TimeReport
|
| Timer (bool run=true) |
| Constructor. More...
|
|
|
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 it 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. More...
|
|
void | start () |
| Start the time counters. More...
|
|
void | stop () |
| Stop the time counters. More...
|
|
void | halt () |
| Halt (i.e stop immediately) the time counters. More...
|
|
int | running () |
| Returns the running state of the timer. More...
|
|
void | restart () |
| Restart the time counters. More...
|
|
|
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. More...
|
|
double | cSystemTime () const |
| Gives back the ellapsed user time of the process' children. More...
|
|
double | realTime () const |
| Gives back the ellapsed real time.
|
|
| operator TimeStamp () const |
| Computes the ellapsed time. More...
|
|