#include <sys/time.h> //引入头文件
int main()
{
struct timeval(&t1,NULL);
fun();
gettimeofday(&t2,NULL);
timeuse = (t2.tv_sec - t1.tv_sec) + (double)(t2.tv_usec - t1.tv_usec)/1000000.0;
cout<<"time = "<<timeuse<<endl; //输出时间(单位:s)
}
微信扫一扫
#include <sys/time.h> //引入头文件
int main()
{
struct timeval(&t1,NULL);
fun();
gettimeofday(&t2,NULL);
timeuse = (t2.tv_sec - t1.tv_sec) + (double)(t2.tv_usec - t1.tv_usec)/1000000.0;
cout<<"time = "<<timeuse<<endl; //输出时间(单位:s)
}
相关推荐