Linux user space取得時間方式及計時方式
struct timeval結構內容
struct timeval { time_t tv_sec;/* seconds */ suseconds_t tv_usec;/* microseconds */ }
計算時間範例:
#include<sys/time.h> struct timeval start; struct timeval end; unsigned long interval; /*Get the time point before the delay*/ gettimeofday(&start, NULL); /*Delay 100ms*/ delay(100); /*Get the time point after the delay*/ gettimeofday(&end, NULL); /*Interval */ interval = 1000000 * (end.tv_sec - start.tv_sec) + end.tv_usec - start.tv_usec; printf("interval is %ld\n",interval );
沒有留言:
張貼留言