is there better 32 clock() timing?

Stephen Kellett snail at
Tue Jan 25 06:42:35 EST 2005

>>that time.clock() is inaccurate.  The problem is that the "time.clock()"
>>statement takes several hundred microseconds to execute.

The statement is incorrect. clock() itself isn't slow, but it is 
accessing a resource, the accuracy of which is no better than 1ms.

There are various timers available, documented and undocumented, all of 
which end up at 1ms or 1.1ms, give or take. For anything shorter you 
need QueryPerformanceCounter() (but that *is* a slow call), or use the 
RDTSC instruction which is fast but gives a count of instruction cycles 
executed and is thus not totally accurate (multiple execution pipelines, 
plus multithreading considerations).

You have to choose the system that works best for you. In many cases 
RDTSC works OK.

Stephen Kellett
Object Media Limited
RSI Information:

More information about the Python-list mailing list