QueryPerformanceCounter实现Windows微秒级延时
2013-09-03 12:26
399 查看
windows的Sleep函数,睡眠线程指定毫秒数,可以用来做毫秒延时。对于微秒延时,没有一个现成的函数,但是可以通过QueryPerformanceFrequencyQueryPerformanceCounter来间接实现。原理就是用循环查询的方式不断调用QueryPerformanceCounter(在Winbase.h中)
LARGE_INTEGER freq; LARGE_INTEGER start, end; QueryPerformanceFrequency(&freq); unsigned int us = 100000; LONGLONG count = (us * freq.QuadPart) / (1000 * 1000); QueryPerformanceCounter(&start); count = count + startQuadPart ; do { QueryPerformanceCounter(&end); }while(end.QuadPart< count); printf("us %u, elaps %u ms\r\n", us, tpend-tpstart);
相关文章推荐
- QueryPerformanceCounter实现Windows微秒级延时
- 用QueryPerformanceCounter实现Windows XP 下微秒级延时
- 高精度计时器QueryPerformanceCounter正确的打开方式(windows环境下)
- [转]windows下实现微秒级的延时
- windows下实现微秒级的延时
- windows平台时间函数性能比较QueryPerformanceCounter,GetTickCount,ftime,time,GetLocalTime,GetSystemTimeAsFileTim
- Windows编程微秒级延时的实现
- windows下实现微秒级的延时
- (转)windows平台时间函数性能比较QueryPerformanceCounter,GetTickCount,ftime,time,GetLocalTime,GetSystemTimeAsFileTime
- windows平台时间函数性能比较QueryPerformanceCounter,GetTickCount,ftime,time,GetLocalTime,GetSystemTimeAsFileTime
- windows平台时间函数性能比较QueryPerformanceCounter,GetTickCount,ftime,time,GetLocalTime,GetSystemTimeAsFileTim
- 实现毫秒级和纳秒级计数的几个API--timeGetTime、GetTickCount、QueryPerformanceCounter
- windows平台时间函数性能比较QueryPerformanceCounter,GetTickCount,ftime,time,GetLocalTime,GetSystemTimeAsFileTim
- windows下实现微秒级的延时
- windows下实现微秒级的延时
- windows下实现微秒级延时
- WinAPI: QueryPerformanceCounter - 获取高性能定时器的当前值
- 时间的函数,sleep,clock,gettickcount,QueryPerformanceCounter(转)
- QueryPerformanceCounter函数
- 精确获取时间(QueryPerformanceCounter)