강현태

Add timer.c for measuring labtime.

File mode changed
1 +#include <stdio.h>
File mode changed
File mode changed
1 +#include <timer.h>
2 +
3 +long tic(void){
4 + struct timespec time_spec;
5 + clock_gettime(CLOCK_THREAD_CPUTIME_ID,&time_spec);
6 + return time_spec.tv_nsec;
7 +}
8 +
9 +long toc(long prev){
10 + struct timespec time_spec;
11 + int now;
12 +
13 + now = clock_gettime(CLOCK_THREAD_CPUTIME_ID,&time_spec);
14 + return time_speck.tv_nsec - prev;
15 +}
16 +