measuring 1/100th seconds, what function?

Tim Peters tim.peters at gmail.com
Wed Aug 11 01:05:45 CEST 2004


[Jonas Kölker]
> I'm doing a Rubik's Cube timer, so I need a function to measure
> 100ths of a second. ...

Assuming you want to compute wall-time deltas (as opposed to CPU-time
deltas), about the best you can do x-platform is

if sys.platform == "win32":
    from time import clock as now
else:
    from time import time as now

Then use now().  Unsure which branch Cygwin should take.  It's up to
you to determine whether it works "well enough" on each platform you
care about.  Note that on a box connected to a network time-correction
service, time.time can appear to "run backwards" briefly at
unpredictable times.  The same kind of thing can happen on multi-CPU
boxes -- or not, depending on piles of platform details.



More information about the Python-list mailing list