timer.c
327 Bytes
#include <timer.h>
long tic(void){
struct timespec time_spec;
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&time_spec);
return time_spec.tv_nsec;
}
long toc(long prev){
struct timespec time_spec;
int now;
now = clock_gettime(CLOCK_THREAD_CPUTIME_ID,&time_spec);
return time_speck.tv_nsec - prev;
}