En Tue, 09 Feb 2010 13:10:56 -0300, Grant Edwards <inva...@invalid.invalid> escribió:

What's the correct way to measure small periods of elapsed
time.  I've always used time.clock() in the past:

However on multi-processor machines that doesn't work.
Sometimes I get negative values for delta.  According to
google, this is due to a bug in Windows that causes the value
of time.clock() to be different depending on which core in a
multi-core CPU you happen to be on.   [insert appropriate
MS-bashing here]

I'm not sure you can blame MS of this issue; anyway, this patch should fix the problem:
http://support.microsoft.com/?id=896256

Is there another way to measure small periods of elapsed time
(say in the 1-10ms range)?

No that I know of. QueryPerformanceCounter (the function used by time.clock) seems to be the best timer available.

Is there a way to lock the python process to a single core so
that time.clock() works right?

Interactively, from the Task Manager:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/taskman_assign_process.mspx

In code, using SetProcessAffinityMask and related functions:
http://msdn.microsoft.com/en-us/library/ms686223(VS.85).aspx

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to