Surprising (for me) benchmark results...
E. Mark Ping
emarkp at CSUA.Berkeley.EDU
Tue May 1 17:45:27 EDT 2001
In article <XFMail.20010501144036.shaleh at valinux.com>,
Sean 'Shaleh' Perry <shaleh at valinux.com> wrote:
>>
>> start = time.time()
>> f = open("infile.txt", 'r')
>> out = open("outfile.txt", 'w')
>> l = f.readlines()
>> l.sort()
>> out.writelines(l)
>> f.close()
>> out.close()
>> end = time.time()
>>
>> print (end-start), " seconds"
>>
>> Python runtime: 600 ms
>>
>
>realize that readlines() reads the entire file into memory, so the sort was
>100% in memory.
>
>On today's machines reading an entire 4.5 mb file is not that bad, but still
>something to remember.
Yes, that was one of the parameters of the test. All of the
implementations used that method (reading the entire file first). We
even tried a file 10x the size, and the results scaled quite well
(which made sense, since the IO dominated).
--
Mark Ping
emarkp at soda.CSUA.Berkeley.EDU
More information about the Python-list
mailing list