GetTickCount64不可靠

GetTickCount有重置为0的问题,所以用GetTickCount64,在xp下用函数代替GetTickCount64

inline __int64 _GetSysTickCount64()
	{
		LARGE_INTEGER TicksPerSecond = { 0 };
		LARGE_INTEGER Tick;
		if (!TicksPerSecond.QuadPart)
			QueryPerformanceFrequency(&TicksPerSecond);
		QueryPerformanceCounter(&Tick);
		__int64 Seconds = Tick.QuadPart / TicksPerSecond.QuadPart;
		__int64 LeftPart = Tick.QuadPart - (TicksPerSecond.QuadPart*Seconds);
		__int64 MillSeconds = LeftPart * 1000 / TicksPerSecond.QuadPart;
		__int64 Ret = Seconds * 1000 + MillSeconds;
		return Ret;
	};

程序运行3天后发现,测试发现,

__int64 d0 = GetTickCount64();
__int64 d1 = _GetSysTickCount64();
cout <

GetSysTickCount64 和 GetSysTickCount64 同一时刻差距很大真是奇葩啊。看来
GetSysTickCount64 不能用于校时标准了。

GetTickCount64不可靠_第1张图片


你可能感兴趣的:(C++)