summaryrefslogtreecommitdiff
path: root/src/util/timer/timer_linux.c
blob: 6585f10fe8ee5bbb10c42756825628519c00dc87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <time.h>

#include "timer.h"

u64 nn_get_timestamp(void)
{
    struct timespec spec;
    clock_gettime(CLOCK_REALTIME, &spec);
    return 1e6 * spec.tv_sec + spec.tv_nsec * 1e-3;
}

f64 nn_get_tick(void)
{
    struct timespec spec;
    clock_gettime(CLOCK_MONOTONIC, &spec);
    return spec.tv_sec + spec.tv_nsec * 1e-9;
}