gettimeofday sample code
#include < sys/time.h >
#include < stdio.h >
int main()
{
struct timeval tv, tv2;
unsigned long long start_utime, end_utime;
gettimeofday(&tv,NULL);
start_utime = tv.tv_sec * 1000000 + tv.tv_usec;
usleep(1000);
gettimeofday(&tv2,NULL);
end_utime = tv2.tv_sec * 1000000 + tv2.tv_usec;
printf(" runtime = %llu\n", end_utime - start_utime );
}
留言
張貼留言