int vs. float in benchmark testing

David E. Konerding DSD staff dek at pabst.lbl.gov
Fri Feb 20 11:26:19 EST 2004


In article <c15899$ag1$1 at solaris.cc.vt.edu>, Bart Nessux wrote:
> Peter Hansen wrote:
>> Bart Nessux wrote:
>> 
>>>Would adding .0 to each of the numbers below turn this into a floating
>>>point test? Seems too easy.
>>>
>>>def cpu_test():
>>>    import time
>>>    start = time.time()
>>>    x = 0                               # 0.0
>>>    while x < 9999999:                  # 9999999.0
>>>       x = x + 1                                # 1.0
>>>       print x
>>>    print (time.time()-start)/60
>>>cpu_test()
>> 
>> 
>> Uh, yes it would, as far as it goes, but are you sure you're
>> learning something useful by doing so?
> 
> Uh, yes. We're benchmarking different processors. An IBM PPC 970 does 
> things differently than an Intel P4. Running the same bit of Python code 
> on both makes for an interesting comparison. Since processors handle 
> ints and floats differently, it is useful for me to test them both.

I bet (significantly) more time is being spent in the python byte code processing machinery than the
actual chip-level instructions performing the integer and floating point math, so your
processor-differential results will be masked by that.  

Dave



More information about the Python-list mailing list