python disk i/o speed

nnes pruebauno at latinmail.com
Mon Aug 12 12:05:49 CEST 2002


"Karl Vogel" <vogelke at dnaco.net> wrote in message news:<mailman.1028926755.31828.python-list at python.org>...
> Benchmarks on Pentium-200 FreeBSD, /tmp is RAM disk:
> 
>     me% df /tmp
>     Filesystem  1K-blocks     Used    Avail Capacity  Mounted on
>     mfs:34         257998    19234   218126     8%    /tmp
> 
>     me% time ./bench.py in out
>     ./bench.py in out  145.90s user 0.72s system 99% cpu 2:27.97 total
> 
>     me% time ./bench2.py in out
>     ./bench2.py in out  143.74s user 0.73s system 97% cpu 2:28.66 total
> 
>     me% time ./bench3.py in out 
>     ./bench3.py in out  130.80s user 0.54s system 99% cpu 2:12.13 total
> 
>     me% time ./bench.pl in out
>     ./bench.pl in out  98.31s user 0.70s system 99% cpu 1:39.81 total
> 
>     me% time ./bench.c in out
>     ./bench in out  6.48s user 0.55s system 96% cpu 7.259 total
> 

I don´t know where our discrepancy generates. Could be the Python
version 2.1.3 vs 2.2.1 or the Windows vs BSD implementation???

###################bench10.py

import sys,xreadlines,profile,pstats

def filterfile2(inname, outname):

   input = file(inname)
   output = file(outname, 'w')

   localint = int
   l_outwrite = output.write

   for line in input.xreadlines():
       line12 = line[1:-2]
       x, y, z = line12.split('","')
       l_outwrite('"'+line12+'","'+str(localint(x)+localint(y)+localint(z))+'"\n')


   output.close()
   input.close()

if len(sys.argv)<3:
    sys.exit("bench input output")

#filterfile2(sys.argv[1],sys.argv[2])

profile.run('filterfile2(sys.argv[1],sys.argv[2])','filtprof')
p = pstats.Stats('filtprof')
p.sort_stats('time').print_stats()


######################bench9.py

import sys,xreadlines,profile,pstats

def filterfile2(inname, outname):

   input = file(inname)
   output = file(outname, 'w')

   localint = int
   l_outwrite = output.write

   for line in input.xreadlines():
       line12 = line[1:-2]
       x, y, z = line12.split('","')
       l_outwrite('"%s","%s"\n' % (
          line12,localint(x) + localint(y) + localint(z)))

   output.close()
   input.close()

if len(sys.argv)<3:
    sys.exit("bench input output")

#filterfile2(sys.argv[1],sys.argv[2])

profile.run('filterfile2(sys.argv[1],sys.argv[2])','filtprof')
p = pstats.Stats('filtprof')
p.sort_stats('time').print_stats()


######################result

C:\Python22\src>..\python -O bench10.py iii ooo
Mon Aug 12 10:50:10 2002    filtprof

         3 function calls in 73.202 CPU seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall
filename:lineno(function)
        1   73.199   73.199   73.199   73.199
bench10.py:3(filterfile2)
        1    0.003    0.003   73.202   73.202
profile:0(filterfile2(sys.argv[1],
sys.argv[2]))
        1    0.000    0.000   73.200   73.200 <string>:1(?)
        0    0.000             0.000          profile:0(profiler)

C:\Python22\src>..\python -O bench9.py iii ooo
Mon Aug 12 10:51:43 2002    filtprof

         3 function calls in 79.530 CPU seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall
filename:lineno(function)
        1   79.527   79.527   79.527   79.527 bench9.py:3(filterfile2)
        1    0.003    0.003   79.530   79.530
profile:0(filterfile2(sys.argv[1],
sys.argv[2]))
        1    0.000    0.000   79.528   79.528 <string>:1(?)
        0    0.000             0.000          profile:0(profiler)

Nestor



More information about the Python-list mailing list