C++ Windows下使用Sleep(0)睡眠约1~2微妙

测试:

#include<iostream>
#include<Windows.h>

void main()
{
	LARGE_INTEGER cpuFreq;
	LARGE_INTEGER startTime;
	LARGE_INTEGER endTime;
	double runTime = 0;
	QueryPerformanceFrequency(&cpuFreq);
	QueryPerformanceCounter(&startTime);
	Sleep(0);
	QueryPerformanceCounter(&endTime);
	runTime = (((endTime.QuadPart - startTime.QuadPart) * 1000000.0) / cpuFreq.QuadPart);
	cout << runTime << " μs" << endl;
	system("pause");
}

显示微妙级方法修改自https://www.cnblogs.com/chensheng-zhou/p/6323174.html

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭