2019-12-29 10:06:25 +00:00
|
|
|
#include <time.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2019-12-29 10:36:08 +00:00
|
|
|
static inline uint64_t gettime_us(void)
|
2019-12-29 10:06:25 +00:00
|
|
|
{
|
|
|
|
struct timespec ts = { 0 };
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
2019-12-29 10:36:08 +00:00
|
|
|
return ts.tv_sec * 1000000ULL + (double)ts.tv_nsec / 1000ULL;
|
2019-12-29 10:06:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint32_t gettime_ms(void)
|
|
|
|
{
|
|
|
|
struct timespec ts = { 0 };
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
|
|
|
return ts.tv_sec * 1000UL + ts.tv_nsec / 1000000UL;
|
|
|
|
}
|