QueryUnbiasedInterruptTime 是单调的吗?

编程入门 行业动态 更新时间:2024-10-25 18:32:25
本文介绍了QueryUnbiasedInterruptTime 是单调的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在尝试在 Windows 上为 clock_gettime(CLOCK_MONOTONIC)mach_absolute_time 找到合适的替代品.

I'm trying to find a decent replacement on Windows for clock_gettime(CLOCK_MONOTONIC) and mach_absolute_time.

GetTickCount 很烦人,因为它是故意偏向的:当系统从挂起或休眠状态恢复时,似乎 Windows 计算出它被挂起的时间(从主板)然后将其添加到滴答计数中它看起来像是在系统断电时进行的滴答声.

GetTickCount is annoying because it's deliberately biased: when the system resumes from suspend or hibernation, it seems Windows works out how long it was suspended (from motherboard) then adds that to the tick count to make it look like the tick carried on while the system was powered down.

QueryUnbiasedInterruptTime 更友好:它是一个简单、看似可靠的计数器,只返回系统自启动以来运行的时间.

QueryUnbiasedInterruptTime is friendlier: it's a simple, seemingly-reliable counter that just returns the time the system has been running since boot.

现在,我已经尝试了 QueryUnbiasedInterruptTime 以了解当计算机进入以下各项时会发生什么:睡眠、混合睡眠和休眠.它似乎已正确更新,因此它看起来是单调的(即,系统在休眠之前将其隐藏并恢复,以便应用程序不会混淆).

Now, I've experimented with QueryUnbiasedInterruptTime to see what happens when the computer enters each of: sleep, hybrid sleep, and hibernation. It appears that it's correctly updated so that it appears to be monotonic (ie, the system stashes it before hibernation and restores it so that applications aren't confused).

但是,在 Python 开发页面上有一个注释(顺便说一句,这是一个非常有用的时间函数参考资源!):

But, there's a note here on the Python dev pages (which, by the way, are a very helpful resource for time function reference!):

QueryUnbiasedInterruptTime() 不是单调的.

QueryUnbiasedInterruptTime() is not monotonic.

我想有人进行了测试以确定这一点.那个信息准确吗?如果是这样,出于兴趣,我想知道您必须做什么才能使返回值倒退.

I presume someone did a test to determine that. Is that information accurate? If so, out of interest I wonder what you have to do to get the return value to go backwards.

推荐答案

QueryUnbiasedInterruptTime 保证是单调的.中断时间没有添加任何偏差,因此它总是向前滴答,尽​​管速率有时可能与挂钟略有不同.

QueryUnbiasedInterruptTime is guaranteed to be monotonic. The interrupt time has no skew added to it, so it always ticks forward although the rate may sometimes differ a little from the wall clock.

我在 MSDN 中找不到任何好的参考资料,但我现在确信 Hans 的评论是正确的,CPython 开发人员一定只是感到困惑.

I couldn't find any good references for this in MSDN, but I'm now convinced that Hans is right in his comment, the CPython developers must have simply got confused.

这篇关于QueryUnbiasedInterruptTime 是单调的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 12:42:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1393618.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单调   QueryUnbiasedInterruptTime

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!