#include "time.h"
using namespace std;
int main(){
clock_t start, finish;
double time_length;
start = clock();//start
//计算时间的代码片
finish = clock();//finish
time_length = (double)(finish - start) / CLOCKS_PER_SEC;//根据两个时刻的差,计算出运行的时间
cout<<"Time used is "<<time_length<<" second."<<endl;
return 0;
}
C++计算代码片运行时间
最新推荐文章于 2024-06-22 17:14:28 发布