windows下实现微秒级延时
来源:互联网 发布:c语言学生成绩管理删除 编辑:程序博客网 时间:2024/06/07 02:01
//常规
void sleep_micro_seconds(ULONG ulMicroSeconds)
{
LARGE_INTEGER varFrequency = {0}, varCounter_Start = {0}, varCounter_End = {0};
double dFrequency = 0;
LONGLONG llCount = 0;
::QueryPerformanceFrequency(&varFrequency);
dFrequency = varFrequency.QuadPart/1.0;
::QueryPerformanceCounter(&varCounter_Start);
while(true)
{
::QueryPerformanceCounter(&varCounter_End);
llCount = varCounter_End.QuadPart - varCounter_Start.QuadPart;
if((llCount/dFrequency) > (ulMicroSeconds/1000000.0) )
{
break;
}
}
}
//优化
void sleep_micro_seconds(ULONG ulMicroSeconds)
{
LARGE_INTEGER varFrequency = {0}, varCounter_Start = {0}, varCounter_End = {0};
LONGLONG llCount = 0;
::QueryPerformanceFrequency(&varFrequency);
::QueryPerformanceCounter(&varCounter_Start);
while(true)
{
::QueryPerformanceCounter(&varCounter_End);
llCount = varCounter_End.QuadPart - varCounter_Start.QuadPart;
if(1000000*llCount > ulMicroSeconds*varFrequency.QuadPart)
{
break;
}
}
}
int main(int argc, char* argv[])
{
sleep_micro_seconds(40);
}
- windows下实现微秒级的延时
- windows下实现微秒级的延时
- windows下实现微秒级延时
- 用QueryPerformanceCounter实现Windows XP 下微秒级延时
- [转]windows下实现微秒级的延时
- QueryPerformanceCounter实现Windows微秒级延时
- Windows编程微秒级延时的实现
- QueryPerformanceCounter实现Windows微秒级延时
- STM32Cubemx下实现通用定时器微秒级延时
- stm32微秒延时实现
- 微秒级延时
- 微秒级延时
- VC 微秒级延时函数
- STM32 使用通用计时器实现微秒延时
- STM32 使用通用计时器实现微秒延时
- STM32 使用通用计时器实现微秒延时
- WINCE 微秒、毫秒级延时函数
- WinCE 微秒和毫秒级延时函数
- 用jxl 从jsp页面导出数据到excel表格并下载保存
- Win7设置FTP详细过程
- android 中chromium_org模块打log的方法
- mtd块设备缓冲操作---mtdblock.c
- hadoop Unable to load native-hadoop library --解决
- windows下实现微秒级延时
- CXF javax.xml.ws.soap.SOAPFaultException: Fault occurred while processing
- 改善代码质量的6种重构模式
- 开源游戏3D引擎之Godot的专用脚本语言
- 书籍总结
- Struts2注解Convention扫描jar中的Action的设置
- 利用Cookie统计UV流量
- Question
- 技术好地方