QueryPerformanceCounter question.

Started by
1 comment, last by SpaceRogue 20 years, 9 months ago
I noticed that QueryPerformanceCounter uses a signed LARGE_INTEGER to store the time value. Isn''t this a little odd? When a wrap-around occurs does QPC start returning negative values or does it catch this and wrap to zero? I''d test it myself but I''m not leaving my PC on that long.
Advertisement
A LARGER_INTEGER is 64 bits. A signed large integer is between 2^63-1 and -(2^63), since you are excluding the sign bit. This is 9,223,372,036,854,775,807 and -9,223,372,036,854,775,808.

On my machine, the performance counter frequency is 1,680,440,000 ticks per second.

Dividing 9,223,372,036,854,775,807 by 1,680,440,000 gives 5,488,664,895 (that's max upper limit in total seconds for a performance counter).

5,488,664,895 seconds is 91,477,748.25 minutes or 1,524,629.1375 hours or 63,526.2140625 days or 173.9253 years.

I don't think you will be around in 173.9253 years, so your question is pretty much moot.

botman

[edited by - botman on July 2, 2003 8:59:35 AM]
Thanks...I''d neved actually done the math to see how often a wrap would occur. I randomly guessed maybe a month or so (well within possible limits for a PC to be turned on)! :O

Interestingly enough, after your example I checked my frequency and my counter runs at about 3.5 million per second, so it will only wrap roughly every eighty thousand years ! Hopefully I''ll have a new PC by then.

This topic is closed to new replies.

Advertisement