From: Matt Armstrong Date: 2002-02-06T02:04:33+09:00 Subject: A case where 1.7 is slower than 1.6 It seems that File#readlines (and similar operations) got significantly slower in ruby 1.7. My test results: % ruby huge.rb This is 1.6.5 2001-11-28 i386-linux read huge file into an array: 3.210000 sec % ruby-cvs huge.rb This is 1.7.2 2002-02-04 i686-linux read huge file into an array: 5.733333 sec And the test program: if Process.respond_to? :times then TIMES_MODULE = Process else TIMES_MODULE = Time end def benchmark( label, times, &block ) begtime = TIMES_MODULE.times.utime times.times( &block ) endtime = TIMES_MODULE.times.utime puts "%s: %f sec" % [ label, endtime - begtime ] end File.open("huge_file", "w") do |f| s = 'a' * 80 0.upto(100000) do f.puts s end end puts "This is %s %s %s" % [ RUBY_VERSION, RUBY_RELEASE_DATE, RUBY_PLATFORM ] benchmark("read huge file into an array", 1) do data = [] File.open("huge_file") do |f| f.each_line do |line| data << line end end end File.delete("huge_file") -- matt