Will QueryPerformanceCounter return the correct value for 32-bit computer that is up for more than month or even a couple of months or years?
Thanks
CodePudding user response:
Microsoft guarantees that QueryPerformanceCounter will not roll over sooner than 100 years from boot: quoting https://docs.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resolution-time-stamps#general-faq-about-qpc-and-tsc
How often does QPC roll over?
Not less than 100 years from the most recent system boot, and potentially longer based on the underlying hardware timer used. For most applications, rollover isn't a concern.
Contra the other answers, you CANNOT deduce this just from the fact that QueryPerformanceCounter produces a 64-bit value. The hardware clock used to implement QPC could have a much smaller range, and Windows could just be zero-extending that clock to 64 bits. This is particularly plausible on the older 32-bit systems you were asking about. Only explicit documentation of the rollover interval should be relied on.
CodePudding user response:
QueryPerformanceCounter does not return a value, it takes a pointer to a large integer. What this large integer is varies based on what you compile the application for.
This large integer in x86 is at least 64 bits in size, with normal visual studio windows.h headers.
