#include <chrono>
int main()
{
auto start = std::chrono::steady_clock::now();
//
//需要被计算运行时间的程序
//
auto end = std::chrono::steady_clock::now();
std::chrono::duration<double, std::milli> elapsed = end - start; // std::micro 表示以微秒为时间单位, std::milli 表示以毫秒为时间单位。
std::cout<< "time: " << elapsed.count()<< "ms" << std::endl;
}
エディタ:C ++でのプログラムの実行中の時間が計算され
、ここで、クロノ記事に専念している:C ++ 11のクロノ包括的な分析(ナノ秒レベルの精度まで)