首页 > 其他 > 详细

测量代码运行时间的模板

时间:2019-07-11 01:41:37      阅读:96      评论:0      收藏:0      [点我收藏+]
#include <iostream>
#include <chrono>
#include <ctime>

int main(){
using namespace std::chrono;
using namespace std;


using _time = steady_clock::time_point;

_time t1 = steady_clock::now();

/*code one*/

_time t2 = steady_clock::now();

duration<double> time_span1 = duration_cast<duration<double>>(t2 - t1);

std::cout << "It took me " << time_span1.count() << " seconds." << endl;

/*code two*/

_time t3 = steady_clock::now();
duration<double> time_span2 = duration_cast<duration<double>>(t3 - t2);
std::cout << "It took me " << time_span2.count() << " seconds." << endl;

return 0;
}

 

测量代码运行时间的模板

原文:https://www.cnblogs.com/MasterYan576356467/p/11167317.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!