使用标准库在Python中检索壁垒时间?

时间:2011-01-14 02:22:14

标签: python time clock standard-library wall-time

如何使用标准库在Python中检索wall-time

This问题,this问题表明clock_gettime(CLOCK_MONOTONIC_RAW)/proc/uptime之类的内容最适合Linux。在Windows上,time.clock()具有所需的效果。

我会使用time.time(),但不保证函数返回monotonically(并且线性地)增加时间值。

1 个答案:

答案 0 :(得分:6)

Victor Stinner写了a Python implementation of a monotonic timer。请参阅http://bugs.python.org/issue10278进行讨论,the docs for the upcoming 3.3 release参考新功能(以C编码)。

还有Monoclock

  

Monoclock是一个Python模块   提供对单调时钟的访问   在类似POSIX的操作系统上有librt

     

兼容性:在CPython上测试   2.6.5,CPython 2.7,pypy 1.3和pypy 1.4。