Calculating Elapsed Time

Christopher Subich csubich.spam.block at spam.subich.block.com
Wed Dec 7 19:01:50 CET 2005


Peter Hansen wrote:
> A few things.
> 
> 1. "Precision" is probably the wrong word there.  "Resolution" seems 
> more correct.
> 
> 2. If your system returns figures after the decimal point, it probably 
> has better resolution than one second (go figure).  Depending on what 
> system it is, your best bet to determine why is to check the 
> documentation for your system (also go figure), since the details are 
> not really handled by Python.  Going by memory, Linux will generally be 
> 1ms resolution (I might be off by 10 there...), while Windows XP has 
> about 64 ticks per second, so .015625 resolution...

One caevat: on Windows systems, time.clock() is actually the 
high-precision clock (and on *nix, it's an entirely different 
performance counter).  Its semantics for time differential, IIRC, are 
exactly the same, so if that's all you're using it for it might be worth 
wrapping time.time / time.clock as a module-local timer function 
depending on sys.platform.



More information about the Python-list mailing list