diff --git a/src/lib/utils.c b/src/lib/utils.c index 1d383ad..7a53c61 100644 --- a/src/lib/utils.c +++ b/src/lib/utils.c @@ -210,3 +210,10 @@ long clock_micros(void) { clock_gettime(CLOCK_MONOTONIC, &time); return time.tv_sec * 1000000 + time.tv_nsec / 1000; } + + +long clock_cpu(void) { + struct timespec time; + clock_gettime(CLOCK_THREAD_CPUTIME_ID, &time); + return time.tv_sec * 1000000000 + time.tv_nsec; +} diff --git a/src/lib/utils.h b/src/lib/utils.h index 504682d..56aeb05 100644 --- a/src/lib/utils.h +++ b/src/lib/utils.h @@ -39,4 +39,6 @@ int base64_encode(void *data, unsigned long data_len, char *output, unsigned lon long clock_micros(void); +long clock_cpu(void); + #endif //SESIMOS_UTILS_H