Biorbd Release_1.13.0
Loading...
Searching...
No Matches
Timer.h
1#ifndef BIORBD_UTILS_TIMER_H
2#define BIORBD_UTILS_TIMER_H
3
4#include "biorbdConfig.h"
5
6#include <ctime>
7#include <memory>
8
9namespace BIORBD_NAMESPACE {
10namespace utils {
11
15class BIORBD_API Timer {
16 public:
21 Timer(bool startNow = false);
22
26 void start();
27
32 bool isStarted();
33
37 void pause();
38
42 void resume();
43
49 double getLap();
50
55 double stop();
56
57 protected:
62 void addPauseTime();
63
69 double getTime(const std::clock_t& timer);
70
73 std::clock_t m_start;
74 std::clock_t m_pauseTime;
76};
77
78} // namespace utils
79} // namespace BIORBD_NAMESPACE
80
81#endif // BIORBD_UTILS_TIMER_H
double getTime(const std::clock_t &timer)
Get the time spent until start.
Definition Timer.cpp:70
bool isStarted()
Return if the timer is started.
Definition Timer.cpp:24
Timer(bool startNow=false)
Construct timer.
Definition Timer.cpp:6
std::clock_t m_pauseTime
The pause time.
Definition Timer.h:74
bool m_isPaused
If the timer is paused.
Definition Timer.h:72
bool m_isStarted
If the timer is started.
Definition Timer.h:71
void start()
Start the timer.
Definition Timer.cpp:17
void resume()
Resume the timer. If it is paused, it adds a lap.
Definition Timer.cpp:33
double getLap()
Get the lap time of a running timer. Return 0 if the timer is not running.
Definition Timer.cpp:44
void addPauseTime()
Add a pause to the timer time (total time being execution time - pause time).
Definition Timer.cpp:63
std::clock_t m_start
The start time.
Definition Timer.h:73
double m_totalPauseTime
The total pause time.
Definition Timer.h:75
double stop()
Stop the timer and return the lap time.
Definition Timer.cpp:54
void pause()
Pause the timer.
Definition Timer.cpp:26