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