From: Pete McBreen Date: 2002-03-08T02:36:27+09:00 Subject: Re: file reading impossibly slow? 1.6.6 vs. 1.6.2 numbers Peter Hickman suggested another test, so here are my results from Windows NT4 D:\ruby\bin\test>\ruby162a\bin\ruby -v ruby 1.6.2 (2000-12-18) [i386-cygwin] D:\ruby\bin\test>\ruby162a\bin\ruby testfile.rb 1.672 1.572 D:\ruby\bin\test>ruby -v ruby 1.6.6 (2001-12-26) [i586-mswin32] D:\ruby\bin\test>ruby testfile.rb 30.414 31.736 Same script, but the 1.6.6 version is _18_ times slower than the old 1.6.2 cygwin version. And in case anyone is wondering about buffering, the times are consistent when I alternate running the 1.6.6 and 1.6.2 versions. I'd have to guess that there is something about the 1.6.6 mswin32 build that is causing the grief, and/or the old cygwin build was really great:-) The script is slightly different than Peter Hickman's, mainly because I wanted to keep the file around. It is also only 100,000 records (2.4 MB) #!ruby tf = File.new("data.txt", "w+") (1..100000).each {|i| tf.print "Here is a line of text\n" } tf.close tf = File.new("data.txt") t1 = Time.now tf.each_line {|line|} puts Time.now - t1 tf.close tf = File.new("data.txt") t1 = Time.now while(!tf.eof?) line = tf.gets end puts Time.now - t1 tf.close I trust someone can figure this out, Pete ---- Pete McBreen, McBreen.Consulting , Cochrane, AB email: petemcbreen@acm.org http://www.mcbreen.ab.ca/ Author, "Software Craftsmanship The New Imperative" Addison-Wesley (C) 2002 http://www.amazon.com/exec/obidos/ASIN/0201733862 Finalist for the 2002 Jolt Awards