#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>



int main()
{
    struct timeval tpstart,tpend;
    float timeuse;
    gettimeofday(&tpstart,NULL);    
    
    
    for(int i=0;i<10;i++)
    {
        usleep(200000);//暂停200ms
    }



    gettimeofday(&tpend,NULL);
    timeuse=1000000*(tpend.tv_sec-tpstart.tv_sec)+tpend.tv_usec-tpstart.tv_usec;
   timeuse/=1000000;
  printf("Used Time:%f\n",timeuse);
   return 0;
}

http://www.cnblogs.com/eavn/archive/2010/08/29/1811878.html

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-26
  • 2022-01-28
  • 2022-12-23
  • 2021-09-30
猜你喜欢
  • 2021-06-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
  • 2022-02-07
  • 2021-12-28
相关资源
相似解决方案