Determining actual elapsed (wall-clock) time

Peter Hansen peter at engcorp.com
Sat Jul 2 16:11:39 EDT 2005


I would like to determine the "actual" elapsed time of an operation 
which could take place during a time change, in a platform-independent 
manner (at least across Linux/Windows machines).

Using time.time() doesn't appear to be suitable, since time might jump 
forwards or backwards at the user's whim, if the system clock is reset, 
or when a daylight savings time change occurs.

Using time.clock() doesn't appear to be suitable on Linux, though it 
appears sufficient on Windows.  (I'm willing to assume nobody will reset 
whatever QueryPerformanceCounter() uses to return the time.clock() value 
on Windows.)

There used to be a "timing" module (according to 
http://effbot.org/librarybook/timing.htm) which would likely have worked 
(for Unix at least), but it's not in the latest Pythons.

I can deal with wraparounds if necessary.  I'm not too concerned about 
the resolution, though better than one second would be useful.

Thanks for any suggestions.

-Peter



More information about the Python-list mailing list