Closed
Description
Feature or enhancement
Proposal:
Actually, this is a performance bug. Not a feature/enhancement.
clock_gettime_ns()
does not use floating point operations and should be faster than old gettimeofday()
. Unfotunately in Python it's not so. Checked in Linux X86_64 kernel 6.5.7, CPython 3.11.6
In [11]: timeit time.clock_gettime_ns(0) # CLOCK_REALTIME
55.4 ns ± 1.22 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
In [12]: timeit time.clock_gettime_ns(5) # CLOCK_REALTIME_COARSE
45 ns ± 0.324 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
In [13]: timeit time.time()
36.7 ns ± 0.953 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response