Project

General

Profile

Bug #2992 » test_file_read.rb

phiggins (Pete Higgins), 03/21/2010 05:34 AM

 
require 'digest/md5'

test_file = "delete_me"
File.open( test_file, "w" ) {|f| f << "0" * 1_000 }

def buffered_read(path)
data = ""
buf = ""
File.open(path, "rb") do |f|
while f.read(16384,buf)
data << buf
end
end
data
end

puts "Pid: #{Process.pid}"
STDIN.gets

100.times do
buffered_read( test_file )
end

GC.start
puts "done"
STDIN.gets

require 'fileutils'
FileUtils.rm( test_file )
(2-2/2)