From: Shannon Fang Date: 2002-12-19T04:39:08+09:00 Subject: Re: hash vs. array (dictionary lookup) Hi, >This code took 3 or 4 seconds to complete on my 900MHz PIII with 256Mb RAM. > > h = {} > x = ["abd123"] * 90000 > x.each_with_index do |y, i| > h[y + i.to_s] = 1 > end > puts h.size > Very strange. I run my code, which is almost same as above again, it runs very fast. But when I do this: ruby -r profile loadtohash.rb dict.txt It becomes very slow. I did the same thing (-r profile) with the loadtoarray version, it worked just like without profiling... What on earth is happening? Regards, Shannon _________________________________________________________________ STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail