From: Tom Willis Date: 2005-03-11T23:06:24+09:00 Subject: Re: very slow IO (STDIN.gets and puts) on Linux, ruby 1.8.2_pre3 On Fri, 11 Mar 2005 17:23:50 +0900, Navindra Umanee wrote: > MiG wrote: > > So the solution is maybe to use getc and parse lines on my own... > > Maybe you're missing the point. > > The two programs aren't doing the same amount of work; your benchmarks > aren't equivalent. If you change the PHP benchmark slightly, you'll > likely see PHP is just as slow as Ruby. > > [navindra@dot /tmp]$ time php -r 'while (fgets(STDIN));' < FILE > 8.421u 2.334s 0:26.53 40.5% 0+0k 0+0io 2pf+0w > [navindra@dot /tmp]$ time ruby -e 'while gets;end' < FILE > 11.676u 2.586s 0:39.44 36.1% 0+0k 0+0io 11pf+0w > [navindra@dot /tmp]$ time php -r 'while ($blah=fgets(STDIN));' < FILE > 10.680u 2.372s 0:37.83 34.4% 0+0k 0+0io 10pf+0w > > Cheers, > Navin. > > Here's my results on a 14.5 mb file, ruby wins. twillis:~$ time ruby -e 'while gets;end'< HL7Audit.csv real 0m1.481s user 0m0.924s sys 0m0.095s twillis:~$ time php -r 'while($blah=fgets(STDIN));'< HL7Audit.csv real 0m2.327s user 0m1.001s sys 0m0.083s -- Thomas G. Willis http://paperbackmusic.net