void mSleep(int mDelay)//毫秒数 { mDelay *= 1000; //转换成微秒 LARGE_INTEGER t1, t2, freq; QueryPerformanceFrequency(&freq); QueryPerformanceCounter(&t1); do { QueryPerformanceCounter(&t2); } while ((((t2.QuadPart - t1.QuadPart) * 1000 * 1000) / (freq.QuadPart)) < (mDelay)); //微秒比较
}
C++中的Sleep精度只有10毫秒以上才是准确的,比如Sleep(1)实际上可能Sleep了10毫秒,以上mSleep可以解决这个问题
标签:高精度,t2,t1,mDelay,Sleep,QuadPart,sleep,freq From: https://www.cnblogs.com/cnblog-caoliang/p/17021107.html