[Python-Dev] Drop the new time.wallclock() function? (original) (raw)
Michael Foord fuzzyman at voidspace.org.uk
Wed Mar 14 01:03:58 CET 2012
- Previous message: [Python-Dev] Drop the new time.wallclock() function?
- Next message: [Python-Dev] Drop the new time.wallclock() function?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 13 Mar 2012, at 16:57, Victor Stinner wrote:
Hi,
I added two functions to the time module in Python 3.3: wallclock() and monotonic(). I'm unable to explain the difference between these two functions, even if I wrote them :-) wallclock() is suppose to be more accurate than time() but has an unspecified starting point. monotonic() is similar except that it is monotonic: it cannot go backward. monotonic() may not be available or fail whereas wallclock() is available/work, but I think that the two functions are redundant. I prefer to keep only monotonic() because it is not affected by system clock update and should help to fix issues on NTP update in functions implementing a timeout. What do you think?
I am in the middle of adding a feature to unittest that involves timing of individual tests. I want the highest resolution cross platform measure of wallclock time - and time.wallclock() looked ideal. If monotonic may not exist or can fail why would that be better?
Michael
--
monotonic() has 3 implementations: * Windows: QueryPerformanceCounter() with QueryPerformanceFrequency() * Mac OS X: machabsolutetime() with machtimebaseinfo() * UNIX: clockgettime(CLOCKMONOTONICRAW) or clockgettime(CLOCKMONOTONIC) wallclock() has 3 implementations: * Windows: QueryPerformanceCounter() with QueryPerformanceFrequency(), with a fallback to GetSystemTimeAsFileTime() if QueryPerformanceFrequency() failed * UNIX: clockgettime(CLOCKMONOTONICRAW), clockgettime(CLOCKMONOTONIC) or clockgettime(CLOCKREALTIME), with a fallback to gettimeofday() if clockgettime(*) failed * Otherwise: gettimeofday() (wallclock should also use machabsolutetime() on Mac OS X)
Victor
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk
-- http://www.voidspace.org.uk/
May you do good and not evil May you find forgiveness for yourself and forgive others May you share freely, never taking more than you give. -- the sqlite blessing http://www.sqlite.org/different.html
- Previous message: [Python-Dev] Drop the new time.wallclock() function?
- Next message: [Python-Dev] Drop the new time.wallclock() function?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]