blob: 00b1d34121c6e7983b8ccc2f9786ed3d6e9bceef (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 | #include "driver/uptime.h"
#include <time.h>
uint64_t Uptime::get_s()
{
	struct timespec ts;
	clock_gettime(CLOCK_REALTIME, &ts);
	return ts.tv_sec;
}
uint64_t Uptime::get_us()
{
	struct timespec ts;
	clock_gettime(CLOCK_REALTIME, &ts);
	return ts.tv_nsec / 1000;
}
uint64_t Uptime::get_cycles()
{
	struct timespec ts;
	clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts);
	return ts.tv_nsec;
}
Uptime uptime;
 |