首先定义clock_t start, end;
然后在自己要测试那段代码的前面加上start = clock(); 结尾加上end = clock();
最后用输出语句进行
cout<<"Run time: "<<(double)(end - start) / CLOCKS_PER_SEC<<"S"<<endl;
cout<<"Run time: "<<(double)(end - start)<<"ms"<<endl;
原文地址:http://blog.csdn.net/lxy201700/article/details/30492617