1#include <Misc/Timer.hpp>
6#define MICRO_IN_SECONDS 1000000
11static suseconds_t get_ticks()
14 gettimeofday(&(tmp), NULL);
16 return tmp.tv_usec + (tmp.tv_sec * MICRO_IN_SECONDS);
28 this->startMark = get_ticks();
36 if (!running || paused)
return;
38 this->pausedMark = get_ticks() - (this->startMark);
40 this->running =
false;
45 if (!paused || running)
return;
47 this->startMark = (get_ticks()) - (this->pausedMark);
64 return get_ticks() - this->startMark;
67 return this->pausedMark;
70 if (this->startMark == 0)
73 return (this->pausedMark) - (this->startMark);
void pause()
Temporarily stops the timer.
bool isRunning()
Tells if the timer's still running (hasn't called stop())
void start()
Sets a starting point for the timer.
suseconds_t delta_us()
Returns the whole timer's difference in milisseconds.
void unpause()
Restarts the timer if it was paused.
suseconds_t delta_ms()
Returns the milisseconds part of the timer's difference.
suseconds_t delta_s()
Returns the seconds part of the timer's difference.
bool isPaused()
Tells if the timer's paused.