Surprising (for me) benchmark results...
E. Mark Ping
emarkp at CSUA.Berkeley.EDU
Tue May 1 23:14:41 CEST 2001
Over on the comp.lang.c++ newsgroup (crossposted to the comp.lang.java
group) there was a challenge to read in a large file, sort the lines
lexigraphically, and write them out to a file.
The argument was that Java was faster than C++. It turned out that it
was faster, because my implementation of C++ had an available patch
that I hadn't applied. Anyway, the reults for sorting a 30K line file
(about 4.3MB) were:
Java: ~1500 ms
C++: ~950 ms
Perl: ~1000 ms
And then, just for kicks I wrote the following python script:
start = time.time()
f = open("infile.txt", 'r')
out = open("outfile.txt", 'w')
l = f.readlines()
end = time.time()
print (end-start), " seconds"
Python runtime: 600 ms
Pretty cool. I'm investigating Python as a result of playing around
with Blender, and I'm interested in using python scripting as an
interface for C++ programs (scientific modeling, games, etc.).
This was one impressive result for this Python newbie.
emarkp at soda.CSUA.Berkeley.EDU
More information about the Python-list