C ++ Ubuntuのテストタイムコード

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


cout<<" TimeStart"<<endl;
//时间测量
struct timeval tstart,tend;
double timeUsed;
gettimeofday(&tstart,NULL);
/*待测试代码*/    

/* CODE */

/*待测试代码*/    
gettimeofday(&tend,NULL);
timeUsed=1000000*(tend.tv_sec-tstart.tv_sec)+tend.tv_usec-tstart.tv_usec;
cout<<" Time="<<timeUsed/1000<<" ms"<<endl;

 

公開された32元の記事 ウォン称賛12 ビュー20000 +

おすすめ

転載: blog.csdn.net/BetterEthan/article/details/104047428