#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)
}
计算程序耗时 ,linux 版本 C C++
阅读 96
2022-09-15
#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)
}
相关推荐
精彩评论(0)