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

Steve Holden steve at holdenweb.com
Wed May 24 12:41:06 CEST 2006


M.-A. Lemburg wrote:
> Steve Holden wrote:
[...]
>>>This would be more in line with what time.clock() returns
>>>on Unix platforms, namely the process time... I wonder why
>>>time.clock() doesn't use this API on Windows.
>>>
>>
>>That's a pending change here thanks to Kristjan V Jonsson of CCP, who
>>brought the same code to my attention yesterday. It shouldn't be a
>>difficult fix, so I'll see how it affects reliability. On Windows I
>>can't imnagine it will hurt ...
> 
> 
> 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.
> 
> 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:
> 
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/timers/timerreference/timerfunctions/queryperformancecounter.asp
> 
> This is about at accurate as it'll get on Windows.
> 
> time.time() uses ftime() which is only accurate to the
> millisecond (if at all):
> 
> http://msdn2.microsoft.com/en-us/library/z54t9z5f(VS.80).aspx
> 
The sandbox copy already uses the same code timeit.py uses to determine 
the clock to use. Uncle Timmy points out that the GetProcessTimes() 
isn't ubiquitous, so I don't think there's much point in trying to make 
use of it.

The one change I still do want to make is to allow the use of some 
bogomips-like feature to provide scaled testing to ensure that the 
individual test times can more easily be made large enough.

At that point I'll probably be looking to check it back into the trunk 
as version 1.4 - unless you have any further suggestions? Indications 
are that the timings do seem to be more reliable.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Love me, love my blog  http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden


More information about the Python-checkins mailing list