|
Visual Computing Library
devel
|
The Timer class allows to instantiate simple Timer objects that can be used everywhere. More...
#include <vclib/base/timer.h>
Public Member Functions | |
| 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 | 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. | |
| void | setCaption (const std::string &caption) |
| Sets the caption of the timer. | |
| void | start () |
| Starts the timer. | |
| void | stop () |
| Stops 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. | |
| 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. | |
Private Attributes | |
| std::chrono::high_resolution_clock::time_point | mBegin |
| std::string | mCaption = "Timer" |
| std::chrono::high_resolution_clock::time_point | mEnd |
| bool | mIsStopped = false |
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. |