From: Alex Fenton Date: 2009-03-27T23:16:38+09:00 Subject: Re: Bug: Ruby 1.9.1 File io on Windows is slooooow Damjan Rems wrote: > This simple code shows everything: > > time = [Time.new] > c = '' > 'aaaa'.upto('zzzz') {|e| c << e} > 3.times { c << c } > time << Time.new > File.open('out.file','w') { |f| f.write(c) } > time << Time.new > c = File.open('out.file','r') { |f| f.read } > time << Time.new > 0.upto(time.size - 2) {|i| p "#{i} #{time[i+1]-time[i]}" } > > ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-mswin32] > "0 0.537075" > "1 0.696244" > "2 40.188834" > > ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32] > "0 0.551" > "1 0.133" > "2 0.087" I'm pretty sure from your other message that it's using Ruby 1.9 with UTF-8 encoded strings that kills performance. I get equivalent results on OS X comparing 1.8.6 to 1.9.1 on common string operations like String#[](a_fixnum). It's understandable that correct character-wise operations are much harder for Ruby to implement efficiently on variable-byte-length encodings like UTF-8. Unfortunately, though I was delighted to get proper encoding support in 1.9, the performance hit on strings was a killer on my string-intensive GUI app. There are sometimes ways round this (eg I rewrote diff/lcs to use string character enumerators rather than repeated expensive calls to String#[]). I expect the Ruby team are already aware of the problem, and I hope this is a top priority for 1.9.2. btw, you can report bugs at: http://redmine.ruby-lang.org/ alex