|
Template Numerical Library version\ main:d3a9f32
|
Class for real time, CPU time and CPU cycles measuring. More...
#include <TNL/Timer.h>
Public Member Functions | |
| Timer () | |
| Basic constructor creating a new timer and resets it. | |
| double | getCPUTime () const |
| Returns the elapsed CPU time on this timer. | |
| double | getRealTime () const |
| Returns the elapsed real time on this timer. | |
| void | reset () |
| Reset the CPU and real-time timers. | |
| void | start () |
| Starts timer. | |
| void | stop () |
| Stops (pauses) the CPU and the real-time timers, but does not set them to zero. | |
| bool | writeLog (Logger &logger, int logLevel=0) const |
| Writes a record into the logger. | |
Protected Types | |
| using | Duration = typename std::chrono::high_resolution_clock::duration |
| using | TimePoint = typename std::chrono::high_resolution_clock::time_point |
Protected Attributes | |
| double | initialCPUTime |
| TimePoint | initialRealTime |
| bool | stopState |
| double | totalCPUTime |
| Duration | totalRealTime |
Class for real time, CPU time and CPU cycles measuring.
It measures the elapsed real time and CPU time (in seconds) elapsed on the timer. The timer can be paused by calling stop and start methods and reset by calling reset.
|
nodiscard |
Returns the elapsed CPU time on this timer.
This method returns the CPU time (i.e. time the CPU spent by processing this process) elapsed so far (in seconds). This method can be called while the timer is running, there is no need to use stop method first.
|
nodiscard |
Returns the elapsed real time on this timer.
This method returns the real time elapsed so far (in seconds). This method can be called while the timer is running, there is no need to use stop method first.
| void TNL::Timer::start | ( | ) |
Starts timer.
Starts the CPU and real-time timers. This method can be used also after using the stop method. The timer then continues measuring the time without resetting.
| bool TNL::Timer::writeLog | ( | Logger & | logger, |
| int | logLevel = 0 ) const |
Writes a record into the logger.
| logger | Name of Logger object. |
| logLevel | A non-negative integer recording the log record indent. |