QTimer和Qthread的调度时间精度

在模拟嵌入式设备项目中,通过编写代码测试了QTimer和QThread的msleep函数的时间精度。QT文档指出,QTimer的超时时间可能因系统定时器的准确性而略有延迟,且精度依赖于操作系统和硬件。测试在32位Windows 7环境下,记录了QTimer在不同间隔下的调度误差。
摘要由CSDN通过智能技术生成

最近做的一个模拟嵌入式设备的项目中,要求事件的响应精度在1毫秒左右,特地编写代码测试了一下QTimer和QThread中的msleep函数的时间精度。

QT的帮助中对于QTimer的时间精度问题是这么写的:

Timers will never time out earlier than the specified timeout value and they are not guaranteed to time out at the exact value specified. In many situations, they may time out late by a period of time that depends on the accuracy of the system timers.

The accuracy of timers depends on the underlying operating system and hardware. Most platforms support a resolution of 1 millisecond, though the accuracy of the timer will not equal this resolution in many real-world situations.

If Qt is unable to deliver the requested number of timer clicks, it will silently discard some.

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值