Equivalent of gettimeday() for Windows

前端 未结 5 1457
星月不相逢
星月不相逢 2020-12-23 17:43

Does anyone know an equivalent function of the gettimeofday() function in Windows environment? I am comparing a code execution time in Linux vs Windows. I am us

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-23 18:24

    GetLocalTime() for the time in the system timezone, GetSystemTime() for UTC. If you want a seconds-since-epoch time, use SystemTimeToFileTime() or GetSystemTimeAsFileTime().

    For interval taking, use GetTickCount(). It returns milliseconds since startup.

    For taking intervals with the best possible resolution (limited by hardware only), use QueryPerformanceCounter().

提交回复
热议问题