[issue13261] time.clock () has very low resolution on Linux

Elijah Merkin report at bugs.python.org
Tue Oct 25 11:37:07 CEST 2011


New submission from Elijah Merkin <elm at transas.com>:

time.clock () has very poor time resolution on Linux (tested on Ubuntu 11.04).

The result of call to clock () changes once per several seconds. On the other side, on Windows it provides very good resolution.

Here is a doctest that fails on Linux:
"""
 >>> from time import sleep
 >>> prev = clock ()
 >>> res = True
 >>> for i in xrange(10):
 ...     sleep(0.15)
 ...     next = clock ()
 ...     res = res and (next - prev) > 0.1
 ...     prev = next
 >>> print res
 True
"""

Currently on Linux I am using a workaround that is attached to the issue.

----------
components: None
files: monotime_unix.py
messages: 146347
nosy: ellioh
priority: normal
severity: normal
status: open
title: time.clock () has very low resolution on Linux
type: behavior
versions: Python 2.6, Python 2.7
Added file: http://bugs.python.org/file23515/monotime_unix.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13261>
_______________________________________


More information about the Python-bugs-list mailing list