From: Ron Jeffries Date: 2002-03-08T05:18:56+09:00 Subject: Re: file reading impossibly slow? On Thu, 07 Mar 2002 16:36:22 GMT, Peter Hickman wrote: >Ron Jeffries wrote: > >>Actually, if anything, it is slower. Very interesting ... >> >Odd. Here's my test. > >#!ruby > >require 'tempfile' > >tf = Tempfile.new("data.txt") >(1..1000000).each {|i| tf.print "Here is a line of text\n" } >tf.close > >tf.open >t1 = Time.now >tf.each_line {|line|} >puts Time.now - t1 >tf.close > >tf.open >t1 = Time.now >while(!tf.eof?) > line = tf.gets >end >puts Time.now - t1 >tf.close > >My times are >7.86 and 29.99 on a 500Hz Celeron using Cygwin under Win9, >ruby 1.6.5, and 3.599269 and 9.272985 on my Linux, ruby 1.6.4, >machine which I don't know the spec of. But the ballance >remains the same. My code should have been faster. > My times this time are 134.423 each_line 167.411 gets on a 600 MHz who knows what Toshiba, running win 2000 without cygwin, Ruby 1.6.6, Andy's Windows build. Last time it was slower in each_line but maybe I was doing something else also. My file is about 20x larger in size, and 6x larger in line count. I was running (roughly) 20 times slower than these figures. So that hangs together sort of OK. It really looks like I should be running Linux, doesn't it? But I suppose everyone knew that. I just don't know that I have the patience ... I guess until I figure out whether I can run 1.7, these figures are pretty solid. Smalltalk just goes faster, that's all. I'll run this test on it sometime when I get a chance, just for another comparison. Thanks ... Ronald E Jeffries http://www.XProgramming.com http://www.objectmentor.com I'm giving the best advice I have. You get to decide whether it's true for you.