Sample usage:
struct timeval start, end;
gettimeofday(&start, NULL);
usleep(2000);
gettimeofday(&end, NULL);
usleep(2000);
gettimeofday(&end, NULL);
printf("%ld milliseconds\n", ((end.tv_sec-start.tv_sec) * 1000 + (end.tv_usec-start.tv_usec)/1000.0));
Moreover, we can even speed up this function!
According to this post, we can enable Virtual Dynamic Shared Object to speed things up.
# echo 2 > /proc/sys/kernel/vsyscall64
1 comment:
這讓我想到當年在uiuc搞embedded lab的時光 XD
Post a Comment