低精度测量时间
头文件
#include <time.h>
程序:
clock_t start, end;
start = clock();
// 测试的程序
std::cout << "time consume: " << (double)(clock() - start) / CLOCKS_PER_SEC << std::endl;
高精度测量时间
#include <chrono>
auto startTime = std::chrono::high_resolution_clock::now();
// your code
auto endTime = std::chrono::high_resolution_clock::now();
float totalTime = std::chrono::duration<float, std::milli>
(endTime - startTime).count();