[Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py
M.-A. Lemburg
mal at egenix.com
Wed May 24 12:58:05 CEST 2006
Tim Peters wrote:
> [M.-A. Lemburg]
>> I gave it a go, but the results are not very promising (or
>> I did something wrong). The UserTime value does change, but
>> it seems to measure something different than process time, e.g.
>> if you run "while 1: pass" for a while, the value doesn't
>> change.
>
> 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).
I did the next best thing:
win32process.GetProcessTimes(win32process.GetCurrentProcess())
Looking at the win32 docs, the GetCurrentProcess() returns an
int where GetProcessTimes() wants a PyHANDLE.
Shouldn't have known better though to actually *look* at
the return value of GetCurrentProcess():
-1
Looks like I should have used OpenProcess() instead.
Anyway, the path looks about right... I'll leave digging up
the win32 details to a Windows geek instead ;-)
>> I've also had a look at the implementation of time.time()
>> vs. time.clock(): time.clock() is definitely more accurate
>> on Windows since it uses the high resolution performance
>> counter:
>
> time.clock() has sub-microsecond resolution (better than a millionth
> of a second) on all flavors of Windows.
>
> time.time() has poor resolution on all flavors of Windows, and is
> extraordinarily expensive to call on some flavors of Windows. The
> resolution depends in part on HW configuration. Most common are
> updating 18.2 times per second (0.055 second resolution) or 100 times
> per second (0.01 second resolution). As a result, if you call
> time.time() twice in a row on Windows, it's likely you'll get exactly
> the same value both times.
>
>>>> from time import time
>>>> print time(), time(), time()
> 1148467169.97 1148467169.97 1148467169.97
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, May 24 2006)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
More information about the Python-checkins
mailing list