windows下获取精确的时间

GetTickCount()精度太低。

http://www.cppblog.com/deane/articles/113151.html

 

#include "windows.h" 

double GetTickCountA()
{
	__int64 Freq = 0;
	__int64 Count = 0;
	if (QueryPerformanceFrequency((LARGE_INTEGER*)&Freq)
		&& Freq > 0
		&& QueryPerformanceCounter((LARGE_INTEGER*)&Count))
	{
		//乘以1000,把秒化为毫秒
		return (double)Count / (double)Freq * 1000.0;
	}
	return 0.0;
}

你可能感兴趣的:(其他)