measuring 1/100th seconds, what function?

Peter Hansen peter at engcorp.com
Tue Aug 10 17:30:14 EDT 2004


Jonas Kölker wrote:

> I'm doing a Rubik's Cube timer, so I need a function to measure 100ths of
> a second. I've browsed through the library reference of python.org, but I
> didn't find anything that struck me as 'the perfect fit'. Either it was
> system dependent, or it was too grainy (lo-res), or... something else.

It usually helps to specify what you looked at, and perhaps why you
didn't think it was acceptable, to avoid us retracing your steps...

> so, I need a function which satisfies (in order of importance):
> 
> 1. It can be used to measure time in the range of up to approximately 1
> minute with an accuracy down to 100th-seconds (that's 60000~65536
> different values). Better accuracy is a bonus, longer time-frame is a
> bigger bonus.
> 
> 2. it must run on any version of windows upon which python 2.4 can run

These two constraints cannot be met simultaneously, I believe.
Windows98 does not provide adequate resolution in the timer.

If you are willing to forego Win98 and use only the real Windows OSes,
then I think you get roughly (?) 10ms resolution already with
time.time().  Linux probably gives 1ms resolution or better in pretty
much all cases with time.time().

-Peter



More information about the Python-list mailing list