-
Notifications
You must be signed in to change notification settings - Fork 209
perf_counter_ns() on Windows has changed scale and base reference #973
Description
When I updated FluffOS on Windows 10 from one built in early 2021 to current, the perf_counter_ns() function changed drastically. It now counts microseconds instead of nanoseconds. Also it isn't microseconds since epoch but rather compared to something else. I'm not sure what it's compared to, it's not very large and sometimes is negative.
beb357a added an #ifdef _WIN32 to run some alternate code. I added three more zeroes there and that got it to run at nanosecond scale again. But I didn't know quite what to do to make it counted from epoch again. I found some documentation that says QueryPerformanceCounter is independent of any external time reference, and to use GetSystemTimePreciseAsFileTime for high-resolution time of day measurements. But the same documentation says that QueryPerformanceCounter was introduced with Windows 7 while GetSystemTimePreciseAsFileTime was introduced with Windows 8, so I would not want to suggest leaving Windows 7 behind just to restore the time of day functionality.
The builds prior to that commit all worked good on my Windows 10 PCs. I don't know enough about it to say if it would make sense to change the function from QPC to GetSystemTimePreciseAsFileTime, or to just have it use the old code. If it stays how it is then it should at least be adjusted by some digits to be nano instead of micro.
Anyway, long story short, I have written a change to use the other function, but I hesitate to make a pull request considering it would drop support for Windows 7. atari2600tim@326bba2 has that. It might be better to just revert the other change. But I personally do not understand the advantages that QPC was intended to make compared to the original code, so I do not know which one to suggest.