This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: better timer resolution for
Type: Stage:
Components: Library (Lib) Versions:
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, georg.brandl, jmg, loewis
Priority: normal Keywords: patch

Created on 2002-11-30 00:17 by jmg, last changed 2022-04-10 16:05 by admin. This issue is now closed.

File name Uploaded Description Edit jmg, 2002-11-30 00:17 add resource.getrusage timer
Messages (4)
msg41859 - (view) Author: John-Mark Gurney (jmg) Date: 2002-11-30 00:17
On some platforms time.clock() does not return a high
resolution counter.  On FreeBSD, it's resolution is
only 1/128th of a second.  In order to get microsecond
accuracy, the getrusage syscall from resource needs to
be used.

Attached is a patch that uses getrusage from the
resource library in preference of os.clock.

This was done on behalf of Vernier Networks, Inc.
msg41860 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2003-07-06 20:28
Logged In: YES 

Is there any possibility that using this could lead to worse timing 
under another OS?

And I assume this is still an issue under FreeBSD 5.
msg41861 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-02-23 18:28
Logged In: YES 

If this leads to better resolution on FreeBSD, it seems like
a good idea. However, if you don't know about other OS, what
about restricting the patch to FreeBSD?
msg41862 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-03-03 11:40
Logged In: YES 

I believe getrusage is always the better choice, as clock()
wraps around after 36 minutes on a POSIX system. Committed as 1.62
NEWS 1.1258
Date User Action Args
2022-04-10 16:05:57adminsetgithub: 37556
2009-01-12 13:31:00amaury.forgeotdarclinkissue881261 superseder
2002-11-30 00:17:55jmgcreate