This is something I wrote today to compare the Windows System Precise Filetime with the Unix Time and the elapsed time computed by reading the Windows performance counter.
I welcome comments if there are alternative or better ways of getting time tags and elapsed times out of Windows.
' FILETIME structure
' This structure is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601.
' GetSystemTimePreciseAsFileTime function
' https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime
' Acquiring high-resolution time stamps
' https://docs.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resolution-time-stamps
' time_t time( time_t *destTime )
' Returns the time as seconds elapsed since midnight, January 1, 1970, or -1 in the case of an error.
' https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/time-time32-time64?view=vs-2019
' 64-bit OS, time_t type is 8 byte _INTEGER64
' 32-bit OS, time_t type is 4 byte INTEGER
PRINT " System Precise FILETIME, UNIX TIME, Elapsed Performance Counter" QueryPerformanceFrequency
(_OFFSET(Frequency
))QueryPerformanceCounter
(_OFFSET(StartingCount
))
GetSystemTimePreciseAsFileTime
(_OFFSET(ft
))
' UNIX time
time_now& = time(0)
QueryPerformanceCounter
(_OFFSET(PerformanceCount
))
' Elasped Performace Count
dElapsedTime
= (CDBL(PerformanceCount
- StartingCount
)) / Frequency
' System Precise FileTime
qwResult = ft.dwHighDateTime
qwResult = qwResult * &H100000000
qwResult = qwResult + ft.dwLowDateTime
PRINT CDBL(qwResult
) / 10000000.0 - 11644473600.0, time_now&
, dElapsedTime