Project

General

Profile

Backport #2722

Updated by jeremyevans0 (Jeremy Evans) over 5 years ago

=begin 
  
  This problem occurs on 1.8.6, 1.8.7 and 1.9.1 (all the versions I tested) 
 
  This simple script demonstrates the problem: 
 
  # 100 MB 
  n = 100 * 1000 * 1000 
  puts "writing" 
  File.open("foo", 'wb'){|f| f.write(" " * n) } 
  puts "reading" 
  File.open("foo", 'rb') do |io| 
    io.gets 
  end 
 
  This takes about 1911 seconds. Using a 10MB file completes in 19 seconds, instead of in 1/10th the time as you would imagine. Similarly a 1MB file completes in 0.18 seconds. 
 
 =end 
 

Back