Library API#
Timestamp Functions#
- win_precise_time.time() float #
Return the time in seconds since the epoch as a floating point number. See
time.time()
for a detailed description. This function provides a timestamp with <1us resolution while the builtintime()
function has a resolution of around 15ms.- Returns:
timestamp in seconds
Sleep Functions#
- win_precise_time.sleep(secs: float, /) None #
Suspend execution of the calling thread for the given number of seconds. See
time.sleep()
for a detailed description. This function provides the same accuracy as the Python 3.11 implementation. Earlier Python version were unable to achieve sub-millisecond precision.- Parameters:
secs (float) – the sleep duration in seconds
- win_precise_time.sleep_until(t_wakeup_s: float, /) None #
Suspend execution of the calling thread until
time()
== t_wakeup_s.
- win_precise_time.sleep_until_ns(t_wakeup_ns: int, /) None #
Suspend execution of the calling thread until
time_ns()
== t_wakeup_ns.
- win_precise_time.hotloop_until_ns(t_wakeup_ns: int, /) None #
Run a busy loop until
time_ns()
== t_wakeup_ns. This function fully loads the CPU core and does not release the global interpreter lock (GIL). This function must only be used for very short wait time to achieve the highest wakeup time precision.Warning
hotloop_until_ns()
makes the process unresponsive. It is only useful for very short high precision waiting.