Visual Computing Library
|
The Timer class allows to instantiate simple Timer objects that can be used everywhere. More...
#include <vclib/misc/timer.h>
Public Member Functions | |
Timer (bool _start=true) | |
Creates a timer with the caption "Timer". If the given boolean is true, the timer starts. | |
Timer (const char *caption, bool _start=true) | |
Creates a timer with the given caption. If the given boolean is true, the timer starts. | |
Timer (const std::string &caption, bool _start=true) | |
Creates a timer with the given caption. If the given boolean is true, the timer starts. | |
void | start () |
Starts the timer. | |
void | stopAndPrint () |
Stops the timer and prints the time passed between the call of start() and this member function. Printed time is expressed in seconds. | |
void | stop () |
Stops the timer. | |
void | print () const |
Prints the time passed between the call of start() and this member function. Works also if the timer is not stopped. Printed time is expressed in seconds. | |
double | delay () const |
Returns the time passed between the call of start() and this member function. Works also if the timer is not stopped. Returned time is expressed in seconds. | |
void | setCaption (const std::string &caption) |
Sets the caption of the timer. | |
Private Attributes | |
std::string | mCaption = "Timer" |
bool | mIsStopped = false |
std::chrono::high_resolution_clock::time_point | mBegin |
std::chrono::high_resolution_clock::time_point | mEnd |
The Timer class allows to instantiate simple Timer objects that can be used everywhere.
When a Timer object is create, by default the timer starts (you can change this option using the bool argument of the Timer constructor). To each timer can be associated a caption, and the printed/returned values are expressed in seconds.
Creates a timer with the caption "Timer". If the given boolean is true, the timer starts.
[in] | _start | if true, the timer will start when the object is created. |
Creates a timer with the given caption. If the given boolean is true, the timer starts.
[in] | caption | the caption of the timer. |
[in] | _start | if true, the timer will start when the object is created. |
Creates a timer with the given caption. If the given boolean is true, the timer starts.
[in] | caption | the caption of the timer. |
[in] | _start | if true, the timer will start when the object is created. |
Sets the caption of the timer.
[in] | caption | the new caption of the timer. |