On Sun, Aug 04, 2024 at 03:50:37PM +0500, Andrey M. Borodin wrote: > There was a bug: when time was not moving on, I was updating used > time by a nanosecond, instead of 1/4096 of millisecond. > V27 fixes that.
+static uint64 get_real_time_ns() +{ + struct timespec tmp; + + clock_gettime(CLOCK_REALTIME, &tmp); + return tmp.tv_sec * 1000000000L + tmp.tv_nsec; +} [...] +static uint64 +get_real_time_ns() +{ + FILETIME file_time; + ULARGE_INTEGER ularge; + + GetSystemTimePreciseAsFileTime(&file_time); + ularge.LowPart = file_time.dwLowDateTime; + ularge.HighPart = file_time.dwHighDateTime; + + return (ularge.QuadPart - epoch) * FILETIME_UNITS_TO_NS; +} +#endif This part of the patch looks structurally wrong to me because we've already spent some time refactoring the clock APIs into instr_time.h that deals about cross-platform requirements for monotonic times. Particularly, on MacOS, we have CLOCK_MONOTONIC_RAW, and your patch does not use it. So you should avoid calling these routines, and build something using the interface unified across the board, like anywhere else. And you know, duplication. The patch has a couple of typos, some spots: - avaiable - incresed_clock_precision -- Michael
signature.asc
Description: PGP signature