-1

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

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?

Note I asked the same question for Posix here.

Community
  • 1
  • 1
Yoric
  • 3,348
  • 3
  • 19
  • 26

1 Answers1

0

No, hibernation time is not reported

How could it?

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.

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.

No gaps in counting

So hibernation time doesn't count either as system time or user time.

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.

1HPET, LAPIC timer or the old good PIT, whatever is available

Community
  • 1
  • 1
  • Well, the question is indeed equivalent to: « Where does `GetThreadTimes` get its data from? Process counters/timers or somewhere else? » But since MSDN doesn't contain any single word on that topic, as far as I can tell, how did you find that info? – Yoric Jul 12 '15 at 08:13
  • @yoric see [here](http://blog.kalmbachnet.de/?postid=28). Or just make a test program that cycle and use `Sleep`. You will read always 0 as the user and system time. To make that test program I had to use an inefficient spin loop- This is enough to understand how thread timings are computed. –  Jul 12 '15 at 09:06