From: Gyoung-Yoon Noh Date: 2005-06-10T05:49:29+09:00 Subject: Re: python/ruby benchmark. Using 'set' is somewhat faster than Hash in 1.9. I've rewritten that code using 'set' as following: require 'set' d = Set.new File.open('/usr/share/dict/words') do |f| d << $_.chop! while f.gets end STDIN.each do |l| puts l unless d.include? l.chop! end Here are timed results in my machine. $ time echo zuul | ruby18 spellcheck-hash.rb zuul real 0m1.688s user 0m1.635s sys 0m0.045s $ time echo zuul | ruby18 spellcheck-set.rb zuul real 0m1.796s user 0m1.748s sys 0m0.048s $ time echo zuul | ruby19 spellcheck-hash.rb zuul real 0m1.694s user 0m1.624s sys 0m0.070s $ time echo zuul | ruby19 spellcheck-set.rb zuul real 0m1.465s user 0m1.411s sys 0m0.053s $ time echo zuul | ~/usr/bin/ruby -rite spellcheck-hash.rb zuul real 0m1.541s user 0m1.485s sys 0m0.054s $ time echo zuul | ~/usr/bin/ruby -rite spellcheck-set.rb zuul real 0m1.178s user 0m1.108s sys 0m0.062s YARV is not that faster in this case. I guess ruby's collection types (Array, Hash, Set...) are not sufficiently optimized than python. I've heard that python 2.4 boosted 'list' performance upto 30% than previous version from a python developer. I got a strong impression on much lower memory usage through 'generator' too. Anyway, ruby is very slower than many other languages. But we can prove not so slower than currently presented in that site. How about discussing about 'howto raise ruby ranking in the shootout site'? ;-) -- http://nohmad.sub-port.net