Determining actual elapsed (wall-clock) time

Peter Hansen peter at engcorp.com
Thu Jul 7 18:20:38 EDT 2005


zooko wrote:
> The traditional use of gettimeofday() to (insecurely and unreliably)
> approximate elapsed local time is one of my pet peeves.
> 
> Fortunately a real monotonic clock has finally been added to the linux
> kernel and glibc:
> 
> http://www.imperialviolet.org/page24.html#e474

Interestingly, the author of that page appears to have made a number of 
the same misassumptions about the actual behaviour of the timeofday 
clock (assuming time.time() fairly faithfully reproduces/wraps that 
behaviour).  Either that or time.time() does magic that avoids the bulk 
of the problems in which case I can say only "sucks not to be using 
Python, doesn't it?"

I'd be more interested in this monotonic clock feature if it were not 
the case that time.time() is pretty much monotonic except in the face of 
the minor (sub-100ms) tweaks that might occur once every week or two 
with an NTP client running.  It certainly doesn't cause the one hour 
jumps forwards and backwards which I and the author of that page both 
thought it would.

-Peter



More information about the Python-list mailing list