MiG wrote:
> Why is Ruby 2x slower in IO than php or bash?
> 
> 
> data.dat is 80 MB file with 5000000 lines. I use Linux, 2GB RAM (tested
> on another pc with similar result).
> 
> --------------------
> 
> test.php:
> #!/usr/bin/php
> <? while (fgets(STDIN)); ?>
> 
> $ time ./test.php < data.dat
> ./test.php < data.dat  5,59s user 0,19s system 88% cpu 6,516 total
> 
> --------------------
> 
> test.rb:
> #!/usr/bin/ruby
> while gets
> end
> 
> $ time ./test.rb < data.dat
> ./test.rb < data.dat  11,51s user 0,31s system 86% cpu 13,598 total
> 

English is so much worse than Japanese!  When I try to count to one 
million in English it takes me 3.42 days, but when I try it in Japanese, 
it only takes me 3.12 days!

Obviously, that means English is the worse language.  Why does English 
suck so bad?!?

-----

In other words: your benchmark is really dumb.  That isn't practical 
code, and trying to draw any conclusions from it is silly.  For Ruby to 
be considered fast, how much time should it take to read and discard a 
line of text 5 kagillion times?  Btw, I found a way to optimize your code:

deleteme.rb
#!/usr/bin/ruby
exit(0)

ben% time ruby deleteme.rb
ruby deleteme.rb  0.00s user 0.00s system 102% cpu 0.006 total

I'm still working on getting it to run in less than 0.004 total.

Ben