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

Tim Peters tim.peters at gmail.com
Wed May 24 12:42:32 CEST 2006


[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'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


More information about the Python-checkins mailing list