[Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py

"Martin v. Löwis" martin at v.loewis.de
Thu May 25 08:31:29 CEST 2006


Tim Peters wrote:
> LOL -- figures ;-)  I haven't used it myself, so can't guess without
> seeing the code.  Best guess is that you passed a process handle for
> some _other_ process (easy to screw up on Windows, because process ids
> and process handles aren't the same things).

Actually, that can't happen: to get a process handle, you either need
to be creator of the process (CreateProcess gives you both the process
id and a process handle), or you must have called OpenProcess. If you
pass an arbitrary integer, you likely get an "invalid handle" error.

> time.clock() has sub-microsecond resolution (better than a millionth
> of a second) on all flavors of Windows.

Are you sure about that? It has a *scale* of sub-microseconds (100ns);
the resolution is unspecified.

clock() uses GetSystemTimeAsFileTime(). This likely reads some
kernel variable, and I very much doubt that this kernel variable
is updated every 100ns. For example, in

http://groups.google.com/group/microsoft.public.win2000.applications/msg/6fba505a7c8ca122?dmode=source

somebody claims that you can get only roughly 10ms resolution
with that function. More generally, I would expect that this
function has the resolution equal to the timer resolution:

http://www.sysinternals.com/Information/HighResolutionTimers.html

To get a finer time measurement, you should use QueryPerformanceCounter.
On x86 processors that support it, this uses rdtsc to fetch the
time-stamping counter:

http://www.lochan.org/2005/keith-cl/useful/win32time.html

Regards,
Martin


More information about the Python-checkins mailing list