为什么通过 timeBeginPeriod 提高计时器分辨率会影响功耗? [英] Why does increasing timer resolution via timeBeginPeriod impact power consumption?

查看:26
本文介绍了为什么通过 timeBeginPeriod 提高计时器分辨率会影响功耗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在用 C# 编写一个应用程序,我需要大约触发一个计时器.每 5 毫秒.根据一些研究,似乎最好的方法是调用 timeBeginPeriod(...) 来改变系统计时器的分辨率.它在我的示例代码中运行良好.

I am currently writing an application in C# where I need to fire a timer approx. every 5 milliseconds. From some research it appears the best way to do this involves p/invoking timeBeginPeriod(...) to change the resolution of the system timer. It works well enough in my sample code.

我在 Larry Osterman 的 MSDN 博客 此条目:

I found an interesting warning about using this function on Larry Osterman's MSDN Blog in this entry:

Adam:调用 timeBeginPeriod 也提高了 GetTickCount 的准确性.

Adam: calling timeBeginPeriod increases the accuracy of GetTickCount as well.

使用 timeBeginPeriod 总的来说是一个非常糟糕的主意 - 我们一直在积极地在 Windows 中删除它的所有用途,因为使用它会带来功耗后果.

using timeBeginPeriod is a hideously bad idea in general - we've been actively removing all of the uses of it in Windows because of the power consumption consequences associated with using it.

有更好的方法可以确保您的线程及时运行.

There are better ways of ensuring that your thread runs in a timely fashion.

有谁知道发生这种情况的确切原因,或者那些更好的方法"(在线程中未指定)可能是什么?我们在谈论多少额外的功耗?

Does anyone know exactly why this occurs, or what those "better ways" (which are unspecified in the thread) might be? How much extra power draw are we talking about?

推荐答案

因为它会导致更多的 CPU 使用.一个很好的解释是在 定时器、定时器分辨率和高效代码的开发.

Because it causes more CPU usage. A good explanation is at Timers, Timer Resolution, and Development of Efficient Code.

这篇关于为什么通过 timeBeginPeriod 提高计时器分辨率会影响功耗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆