From: Dave Thomas Date: 2002-12-19T04:49:53+09:00 Subject: Re: hash vs. array (dictionary lookup) On Wed, 2002-12-18 at 13:39, Shannon Fang wrote: > 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 Profiling intercepts the execution of each Ruby-level statement. Consider the number of statements executed in your two chunks of code. Dave