From: Roger Pack Date: 2010-05-01T05:22:55+09:00 Subject: Re: File.read(fname) vs. File.read(fname,File.size(fname)) Roger Pack wrote: >> user system total real >> straight read 28.875000 18.032000 46.907000 ( 47.812500) >> read w/ size 0.000000 0.031000 0.031000 ( 0.031250) >> >> ...for just a *moderate* 1500x boost in performance. > ... >> It appears that the buffer is being grown linearly, giving O(n^2) >> performance. I'm unable to reproduce this except on windows, so that's where you are, I assume? Yeah unfortunately with windows it does exactly what you described (except in trunk, where it has been fixed, except still has a bit of slowdown when you read files in ascii+translation mode (see last post of this thread: http://www.ruby-forum.com/topic/182875#new) It does seem that the idea results in some speedup, though: linux 1.9.2, 500MB file user system total real normal 0.130000 0.810000 0.940000 ( 0.938607) optimized 0.000000 0.740000 0.740000 ( 0.749340) windows 1.9.2, 500MB file user system total real normal 0.250000 0.671000 0.921000 ( 0.921829) optimized 0.000000 0.764000 0.764000 ( 0.774697) plus results in a huge increase in speed for ascii mode in windows. ruby 1.9.2dev (2010-05-01) [i386-mingw32] user system total real normal 11.342000 0.718000 12.060000 ( 12.735092) optimized 0.000000 0.437000 0.437000 ( 0.446179) (maybe there is still some N^2 action going on?) I'll file a feature request for it. -rp -- Posted via http://www.ruby-forum.com/.