python disk i/o speed

Akio Ito aito at carenet.co.jp
Sun Aug 11 10:55:06 CEST 2002


pruebauno at latinmail.com (nnes) wrote in message news:<d8778a53.0208080317.495eb122 at posting.google.com>...
> Unfortunately the speedup is not near I would have expected. From the
> old 36 seconds down to 33 seconds (using python -O). So I am still
> open to suggestions.
> 
> cheers all
> Nestor
> 

For performance reference here is my version:

######## benchy1.py
from psyco.classes import *
from time import clock

class Test:
    def proc(self):
        finp = file('bigdatain.txt')
        fout = file('bigdataout.txt',"w")
        localint = int
        for line in finp.xreadlines():            
            xline = line[1:-2]
            part0, part1, part2 = xline.split('","')
            s = '"%s","%s"\n' % (xline, localint(part0) + \
                localint(part1) + localint(part2)) # format
            fout.write(s)
        finp.close()
        fout.close()

if __name__ == '__main__':    
    t1 = clock()
    w = Test()    
    w.proc()
    t2 = clock()
    print 'duration= %s' % (t2 - t1)

The results I got where:
with psyco:    4.3 seconds (http://psyco.sourceforge.net/)
nornal python: 5.9 seconds
My machine:
  Win2000 256MB + 40GB hard disk 
  Pentium 4 1.6Ghz
  Python 2.2.1

Regards
Akio Ito



More information about the Python-list mailing list