Files
brightstone/Common/Timer/posix.c
T
2026-10-12 21:12:47 +03:00

19 lines
537 B
C

#include "../std.h"
#include "../time.h"
#include <stdint.h>
#define __USE_POSIX199309 1
#include <time.h>
uint64_t com_timer_count_ns(void) {
struct timespec time;
clock_gettime(CLOCK_MONOTONIC, &time);
return time.tv_sec * 1000000000 + time.tv_nsec;
}
void com_timer_profile(uint64_t starttime, const char *what) {
uint64_t const endtime = com_timer_count_ns();
uint64_t const diff = endtime - starttime;
com_std_print('c', "Profile ", 'c', what, 'c', " took ", 'd',
(double)diff / 1000000, 'c', "ms");
}