From: Dave Thomas Date: 2001-08-16T03:17:01+09:00 Subject: [ruby-talk:19818] Re: how to speed up hash script? gerry@ucar.edu (Gerry Wiener) writes: > I'm in the process of writing a script that will read data from a 17MB > climatology file and then hash the information according to date-time. > The script below takes approximately 14 seconds to run. An analogous > Python script takes 3 seconds to run. Is there a simple way to speed > up the Ruby script? I'm interested in the possibility of using Ruby as > an alternative to Python. You're bumping into the overhead of Ruby's garbage collection. When you have lots of objects lying around, the GC in 1.6 takes a long time to discover what needs to be freed. However, Ruby 1.7 is better. This program runs about 2.5 times as quickly for me using Ruby 1.7, as compared to 1.6. You can simulate the same result with 1.6 by putting a GC.disable before the call to Climo.new, and a GC.enable after it. Or you can upgrade to 1.7, and live on the cutting edge :) Dave