dlinear
0.0.1
Delta-complete SMT solver for linear programming
|
The TimeGuard wraps a timer object and pauses it when the guard object is destructed. More...
#include <Timer.h>
Public Member Functions | |
TimerGuard (Timer *timer, bool enabled, bool start_timer=true) | |
Construct a new TimeGuard object. | |
~TimerGuard () | |
When the timer guard object is destructed, it pauses the embedded timer object. | |
void | Pause () |
Pause the guarded timer object. | |
void | Resume () |
Resume the guarded timer object. | |
Private Attributes | |
Timer *const | timer_ |
The timer to be guarded. | |
const bool | enabled_ {false} |
Whether the timer is enabled. | |
The TimeGuard wraps a timer object and pauses it when the guard object is destructed.
Useful for measuring the exact time spent in a block of code.
dlinear::TimerGuard::TimerGuard | ( | Timer * | timer, |
bool | enabled, | ||
bool | start_timer = true ) |
Construct a new TimeGuard object.
If enabled
is false or timer
is a nullptr, this class does not do anything. If start_timer
is true, starts the timer
in the constructor. Otherwise, it does not start it and a user has to call Resume()
to start it.
timer | a pointer to the timer object to be guarded |
enabled | whether the timer is enabled and should run |
start_timer | whether the timer should be started as soon as the guard is created |
dlinear::TimerGuard::~TimerGuard | ( | ) |