NotificationModule/src/gui/Timer.h

18 lines
390 B
C
Raw Normal View History

2023-01-21 20:37:04 +01:00
#include <ctime>
#include <iostream>
class Timer {
public:
Timer() { clock_gettime(CLOCK_REALTIME, &beg_); }
double elapsed() {
clock_gettime(CLOCK_REALTIME, &end_);
return end_.tv_sec - beg_.tv_sec +
(end_.tv_nsec - beg_.tv_nsec) / 1000000000.;
}
void reset() { clock_gettime(CLOCK_REALTIME, &beg_); }
private:
timespec beg_, end_;
};