This class represents a single timer which measures the execution time of a single thread for a given clock type. More...
#include <stopwatch.h>
Public Member Functions | |
| StopwatchTimer () | |
| Creates a stopwatch that is not running. | |
| void | start () |
| Starts or resumes the stopwatch, if it is not running already. | |
| void | stop () |
| Stops the stopwatch, if it is not stopped already. | |
| double | elapsed (timeunit_t timeunit=timeunit_t::SECONDS) const |
| Returns the time elapsed between the start and stop of the stopwatch in the given unit. | |
| void | reset () |
| Resets the stopwatch. | |
| void | print (const std::string &msg="", timeunit_t timeunit=timeunit_t::SECONDS, std::ostream &os=std::cout) const |
| This method prints out the currently elapsed time. | |
Static Private Member Functions | |
| static size_t | get_current_time () |
| Returns current time of clock_type in nanoseconds. | |
Private Attributes | |
| size_t | beg_ |
| clock (in ns) at which timer was last started | |
| size_t | end_ |
| clock (in ns) at which timer was last stopped (invariant: end_ >= beg_) | |
| size_t | prev_elapsed_ |
| accumulated time of all start-stop intervals since last reset | |
| bool | is_running_ |
| true between start() and stop() | |
This class represents a single timer which measures the execution time of a single thread for a given clock type.
Typical clocks are monotonic wall-time clocks or clocks just measuring cpu time.
|
inline |
Creates a stopwatch that is not running.
References nest::timers::StopwatchTimer< clock_type >::reset().
|
inline |
Returns the time elapsed between the start and stop of the stopwatch in the given unit.
If the stopwatch is running, it returns the time from start until now. If the stopwatch has run previously, the previous runtime is added. If you want only the last measurement, you have to reset the timer, before stating the measurement. Does not change the running state.
|
inlinestaticprivate |
Returns current time of clock_type in nanoseconds.
References nest::timers::SECONDS.
|
inline |
This method prints out the currently elapsed time.
References nest::timers::DAYS, nest::timers::HOURS, nest::timers::MICROSEC, nest::timers::MILLISEC, nest::timers::MINUTES, nest::timers::NANOSEC, and nest::timers::SECONDS.
Referenced by nest::timers::operator<<().
|
inline |
Resets the stopwatch.
Referenced by nest::timers::StopwatchTimer< clock_type >::StopwatchTimer().
|
inline |
Starts or resumes the stopwatch, if it is not running already.
|
inline |
Stops the stopwatch, if it is not stopped already.
|
private |
clock (in ns) at which timer was last started
|
private |
clock (in ns) at which timer was last stopped (invariant: end_ >= beg_)
|
private |
|
private |
accumulated time of all start-stop intervals since last reset