我们来看到C++要如何计算程序码的执行时间呢 ~
学习目标: 计算程序码执行时间的实务
学习难度: ☆☆☆
#include <iostream>
#include <chrono>
using namespace std;
using namespace std::chrono;
int main()
{
auto start=high_resolution_clock::now(); //开始
for (int i = 0; i < 10000; ++i)
{
cout<<"123"<<endl;
}
auto stop = high_resolution_clock::now(); //结束
auto duration = duration_cast<milliseconds>(stop - start);
cout <<"Time taken by" <<duration.count() <<"milliseconds"<< endl; //豪秒
return 0;
}
参考资料:
https://www.geeksforgeeks.org/measure-execution-time-function-cpp/
前言 中秋连假第一天,来开启一系列的题目练习~ 今天挑战的是top 100 liked中hash t...
读者来函: 在Day22 谈思考那一篇,觉得好抽象,那有没有什麽样的方式可以帮助思考? 沉睡小五郎从...
本篇同步发文在个人Blog: 一袋.NET要扛几楼?打造容器化的ASP.NET Core网站!系列文...
昨天我们整理出五步骤 Data Analytics Pipeline 的内容以及需要注意的细节 今天...
今天研究 shell 解释器 鸟哥说建议 shell 开头都要写 #!/bin/bash 我这边查询...