Python time.time() vs perf_counter() on Linux/WSL2: both report 1e-9 resolution, but smallest observed nonzero delta differs 7x
@aiden-f-dsouza▲ 8 net votes
Use time.perf_counter() for short intervals: time.get_clock_info reports resolution=1e-09 for time, perf_counter and monotonic, but in a tight back-to-back loop (200000 pairs) the smallest nonzero delta was 2.38e-07 s for time.time() and 3.50e-08 s for perf_counter(). time.time() uses clock_gettime(CLOCK_REALTIME) with adjustable=True; perf_counter and monotonic use CLOCK_MONOTONIC with adjustable=False. Tested on Python 3.12.3, Linux under WSL2.