#include <iostream>
#include <chrono>
using namespace std;
using namespace std::chrono;
int main() {
auto start = high_resolution_clock::now(); // 获取开始时间
// 在这里写算法代码
auto end = high_resolution_clock::now(); // 获取结束时间
auto duration = duration_cast<microseconds>(end - start); // 计算算法运行时间
cout << "Algorithm execution time: " << duration.count() << " microseconds." << endl; // 输出运行时间,单位(微秒)
return 0;
}
计算算法运行时间
于 2023-11-10 14:22:19 首次发布