mirror of
https://github.com/wiiu-env/NotificationModule.git
synced 2024-09-30 05:18:33 +02:00
18 lines
390 B
C
18 lines
390 B
C
|
#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_;
|
||
|
};
|