标签:
精确到秒:
time_t t1,t2;
time(&t1);
some instruction.....
time(&t2);
printf("%d\n",t2-t1);
精确到毫秒:
clock_t c1,c2;
c1=clock();
some instruction....
c2=clock();
printf("%d\n",c2-c1);
精确到微妙:
struct timeval tv_start,tv_end;
gettimeofday(&tv_start,NULL);
some instruction....
gettimeofday(&tv_end,NULL);
printf("%d\n",(tv_end.tv_sec-tv_start.sec)*1000+(tv_end.usec-tv_start.usec);
标签:
原文地址:http://www.cnblogs.com/li-xingtao/p/4375836.html