clock_t start_t, end_t;
double total_t;
start_t = clock();
std::cout << "程序启动,start_t = " << start_t << std::endl;
for(int i=0; i< data.size(); i++)
{
int a=data[i];
}
end_t = clock();
std::cout << "耗时操作结束,end_t = " << end_t << std::endl;
total_t = (double)(end_t - start_t) / CLOCKS_PER_SEC;
std::cout << "CPU 占用的总时间:" << total_t << std::endl;
测代码消耗时间
最新推荐文章于 2024-03-21 17:41:10 发布