Can QueryPerformanceCounter return negative timestamps?
Dear community,
this is my first time asking a question here, so apologies if I am in the wrong place or have framed the question incorrectly. I have had a bit of trouble finding the right forum and I am willing to delete this post if I am in the wrong spot.
In our software, we use QueryPerformanceCounter and QueryPerformanceFrequency. We were under the impression that QueryPerformanceCounter could return negative, but increasing, timestamps. However, some searching online suggests that on Windows, getting negative timestamps from the high-performance timer, even if monotonically increasing, is a sign of a problem in the system, perhaps even a BIOS configuration issue. For example, see the following discussions:
https://github.com/SFML/SFML/issues/1167
https://stackoverflow.com/questions/31326115/queryperformancecounter-and-weird-results
https://cboard.cprogramming.com/cplusplus-programming/97413-queryperformancefrequency-negative-value.html
https://learn.microsoft.com/en-us/troubleshoot/windows-server/performance/programs-queryperformancecounter-function-perform-poorly
I also saw some discussion that you could get negative timestamps when combining the output of QueryPerformanceCounter with the output of QueryPerformanceFrequency, if QueryPerformanceFrequency had an uncaught exception.
My question is: -> Is any of this true?
Many thanks and best wishes,
Rob
Dear community,this is my first time asking a question here, so apologies if I am in the wrong place or have framed the question incorrectly. I have had a bit of trouble finding the right forum and I am willing to delete this post if I am in the wrong spot.In our software, we use QueryPerformanceCounter and QueryPerformanceFrequency. We were under the impression that QueryPerformanceCounter could return negative, but increasing, timestamps. However, some searching online suggests that on Windows, getting negative timestamps from the high-performance timer, even if monotonically increasing, is a sign of a problem in the system, perhaps even a BIOS configuration issue. For example, see the following discussions:https://github.com/SFML/SFML/issues/1167https://stackoverflow.com/questions/31326115/queryperformancecounter-and-weird-resultshttps://cboard.cprogramming.com/cplusplus-programming/97413-queryperformancefrequency-negative-value.htmlhttps://learn.microsoft.com/en-us/troubleshoot/windows-server/performance/programs-queryperformancecounter-function-perform-poorlyI also saw some discussion that you could get negative timestamps when combining the output of QueryPerformanceCounter with the output of QueryPerformanceFrequency, if QueryPerformanceFrequency had an uncaught exception.My question is: -> Is any of this true?Many thanks and best wishes,Rob Read More