Description
The current implementation of std::time::SystemTime::now on Windows uses the GetSystemTimeAsFileTime function. This function has relatively poor resolution, between 1-16ms depending on the system, which is unacceptable for many real-world applications.
GetSystemTimePreciseAsFileTime on the other hand has a resolution between 1us and 100ns. This extra precision comes at a small performance cost[1], but it is still an extremely lightweight function call. I measured it at 20ns/call on my system. I believe GetSystemTimePreciseAsFileTime should be preferred whenever it is available (Windows Vista and higher)
There seems to be some FUD out there surrounding this function, however Microsoft recommends using this function in this fairly recent article [2] Quote:
When you need UTC-synchronized time stamps with a resolution of 1 microsecond or better, choose GetSystemTimePreciseAsFileTime
See also: Same issue was identified and fixed a couple years ago in the .net runtime: [3]
[1] https://devblogs.microsoft.com/oldnewthing/20170921-00/?p=97057
[2] https://docs.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resolution-time-stamps.
[3] dotnet/coreclr#9736