如何GetThreadTimes报告所花费的时间冬眠? [英] How does GetThreadTimes report time spent hibernating?

查看:171
本文介绍了如何GetThreadTimes报告所花费的时间冬眠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用 GetThreadTimes 来告诉我,我在我的应用程序的事件循环花多少时间。

I am currently using GetThreadTimes to tell me how much time I spend in my application's event loop.

我不知道这将冬眠的影响。正在休眠时间报道呢?或者,也许因为系统时间?是行为上的所有版本的Windows?

I wonder how this will be affected by hibernating. Is hibernation time reported at all? Or perhaps as system time? Is the behavior the same on all versions of Windows?

注意我问的Posix同样的问题<一href=\"http://stackoverflow.com/questions/31246788/how-does-getrusage-report-time-spent-hibernating\">here.

Note I asked the same question for Posix here.

推荐答案

怎么可能呢?

在蛰伏的计算机实际上是的关闭后,没有定时器滴答作响,不计数正在发生。结果
GetThreadTimes 看到的时序在每个刻度系统的计算(即中断)定时器 1

When hibernated the computer is actually turned off, no timer is ticking and no counting is taking place.
The timings you see with GetThreadTimes are computed at each tick (i.e. interrupt) of the system timer1.

我做了一个小的C程序来测试这一点。结果
它记录了每一个计时1000毫秒,我运行和休眠我的笔记本电脑(在第二大约9)。结果
 否的差距显示在计数,符合市场预期,每一行是从previous约1000毫秒。

I've made a small C program to test this.
It logs the timings every 1000 ms, I run it and hibernated my laptop (at second 9 circa).
No gaps are shown in the counting, as expected, each line is about 1000 ms from the previous.

所以休眠时间不计算无论是作为系统时间或用户的时间。

我不知道这是所有旧版本的Windows,特别是与不同的含义冬眠,但你可以期望这是所有重要的版本之间保持一致的结果基本一致。

I don't know it this is consistent with all old versions of Windows, specially the ones with different meaning of hibernation but you can expect this to be consistent among all the important versions.

1 <子> HPET,LAPIC计时器或老好坑,因陋就简

这篇关于如何GetThreadTimes报告所花费的时间冬眠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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