#include<stdio.h>
#include <windows.h>
#include <iostream>
#include <thread>
#include<ctime>
//计时部分初始化
double run_time;
_LARGE_INTEGER time_start; //开始时间
_LARGE_INTEGER time_over; //结束时间
double dqFreq; //计时器频率
LARGE_INTEGER f; //计时器频率
QueryPerformanceFrequency(&f);
dqFreq = (double)f.QuadPart;
//计算耗时
QueryPerformanceCounter(&time_start); //计时开始
//计算一函数的运行时间
QueryPerformanceCounter(&time_over); //计时结束
run_time = 1000000 * (time_over.QuadPart - time_start.QuadPart) / dqFreq;
//乘以1000000把单位由秒化为微秒,精度为1000 000/(cpu主频)微秒
printf("\nrun_time:%fus\n", run_time);
计算算法的运行时间,精确到us(c、window、vs2019)
最新推荐文章于 2024-05-30 07:00:00 发布