#include <sys/time.h>

struct timeval tpstart,tpend;     float timeuse;     gettimeofday(&tpstart,NULL); // 开始时间

 packet();  //usleep(1);//微秒  //sleep(1);//秒  //uppacket();

 gettimeofday(&tpend,NULL);   // 结束时间  // 计算执行时间,以微秒为单位进行计算       timeuse=1000000*(tpend.tv_sec-tpstart.tv_sec)+tpend.tv_usec-tpstart.tv_usec;       timeuse/=1000000;       printf("used time:%f sec\n",timeuse);

posted on 2013-08-15 16:17  draeag  阅读(6201)  评论(0编辑  收藏  举报