is there better 32 clock() timing?
snail at objmedia.demon.co.uk
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.
Object Media Limited http://www.objmedia.demon.co.uk
RSI Information: http://www.objmedia.demon.co.uk/rsi.html
More information about the Python-list