int vs. float in benchmark testing

Bart Nessux bart_nessux at hotmail.com
Fri Feb 20 16:14:49 CET 2004


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.





More information about the Python-list mailing list