From: Yohanes Santoso Date: 2002-06-20T15:56:43+09:00 Subject: Re: Why is I/O slow? --=-=-= Yohanes Santoso writes: > Well, I was intrigue by this, so I tried some of my own: Forgot to attach my test: --=-=-= Content-Disposition: attachment; filename=cat.rb #!/usr/bin/env ruby def with_read_8192(file) while (block = file.read(8192)) != nil $stdout.write(block) end end def with_read_16384(file) while (block = file.read(16384)) != nil $stdout.write(block) end end def with_sysread_8192(file) begin while (block = file.sysread(8192)) $stdout.syswrite(block) end rescue SystemCallError => error p $! rescue EOFError => error #do nothing end end def with_sysread_16384(file) begin while (block = file.sysread(16384)) $stdout.syswrite(block) end rescue SystemCallError => error p $! rescue EOFError => error #do nothing end end File.open(ARGV[0]) { |file| #with_read_8192(file) #with_read_16384(file) #with_sysread_8192(file) with_sysread_16384(file) } --=-=-= YS. --=-=-=--