is there better 32 clock() timing?

Tim Roberts timr at probo.com
Tue Jan 25 03:18:44 EST 2005


Ray Schumacher <rays at blue-cove.com> wrote:
>
>I have a need for a time.clock() with >0.000016 second (16us) accuracy.
>The sleep() (on Python 2.3, Win32, at least) has a .001s limit.
>
>Are they lower/better on other's platforms? 

You need to be careful about describing what you're seeing here.  It is not
that time.clock() is inaccurate.  The problem is that the "time.clock()"
statement takes several hundred microseconds to execute.

>I had also considered forking a thread that would spin a loop checking
>time.clock() and firing the TTL pulse after the appropriate interval,
>but the real, ultimate resolution of time.clock() appears to be 
>~.00035s. If I increase process priority to real-time, it is ~.00028s
>The alternative appears to be more C code...

Are you seriously considering writing a real-time application in Python on
Windows?  The ONLY way to get small-integer microsecond responses in
Windows is to write a kernel driver, and even then there are no guarantees.
Windows is NOT a real-time system.  If you have an environment where an
unexpected delay of a millisecond or more is going to cause damage, then
you need to redesign your application.
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list