Wednesday, July 06, 2005

file fetching stats

I ported the ruby code to python and java for the file finder app. I'd love to use Swing to get out of the GTK pain, but the obesity of the JDK is going to hinder that route.

Here are the results:

time python test.py
18184
--------------------
real 0m0.649s
user 0m0.465s
sys 0m0.182s

time ruby test.rb
19948
--------------------
real 0m0.598s
user 0m0.383s
sys 0m0.195s
--------------------
java -classpath . SimpleTester
19946 took 37 seconds


Couple of interesting things to note:

First, the code running each of these tests is identical in nature--it's a simple recursive walk of a directory tree. The Pyton code came up with signifcantly less (~1800) files because it ignores symlinks. Wonder what two files Java didn't account for that Ruby did.

Second, the Java collection used in the test is a HashSet containing the file names (Strings). Changing the implementation to use an ArrayList of Files added a second or two onto the test.

I should write this also in C++ and post results. For now Ruby is the clear winner and my hunch held true that it's the slimmest and fastest of the three.

Test specs:
Dell D800 P4M 1700mhz
2G Ram
reiserfs
Linux rr800 2.6.11-gentoo-r4 #5 Tue May 3 08:32:04 MDT 2005 i686 Intel(R) Pentium(R) M processor 1700MHz GenuineIntel GNU/Linux

No comments: