Recuperar la pared vez en Python usando la biblioteca estándar?
-
11-10-2019 - |
Pregunta
¿Cómo puedo recuperar tiempo pared en Python usando la biblioteca estándar?
Esta pregunta , y esta pregunta sugeriría que algo como clock_gettime(CLOCK_MONOTONIC_RAW)
o /proc/uptime
son los más apropiados en Linux. En Windows, time.clock()
tiene el efecto deseado.
Me gustaría utilizar time.time()
, pero la función es no se garantizan para volver monótonamente (y linealmente) el aumento de los valores de tiempo.
Solución
Victor Stinner wrote a Python implementation of a monotonic timer. See http://bugs.python.org/issue10278 for the discussion and the docs for the upcoming 3.3 release referencing the new feature (coded in C).
There is also Monoclock:
Monoclock is a Python module that provides access to the monotonic clock on POSIX-like OSes that have
librt
.Compatibility: tested on CPython 2.6.5, CPython 2.7, pypy 1.3, and pypy 1.4.