S
Steve Midgley
Hi Ruby people,
I'm wondering what the functional and performance differences might be
between the two statements below? Assume 'io' is an IO instance with
gobs of data in it. Assume 'file' is an open file instance with write
access:
until io.eof? do
file.write(io.read(10485760))
end
buffer = ''
until io.eof? do
buffer = io.read(10485760)
file.write(buffer)
end
I see that Ruby provides for a buffer and I'm wondering what the
reason is? I read this article but am still not clear on the benefit
of a buffer at all:
http://rcoder.net/content/fast-ruby-io
I'm wondering if providing a buffer might reduce malloc issues and
speed things up? I can't see any other reason to use one..
Thanks in advance for any information!
Steve
I'm wondering what the functional and performance differences might be
between the two statements below? Assume 'io' is an IO instance with
gobs of data in it. Assume 'file' is an open file instance with write
access:
until io.eof? do
file.write(io.read(10485760))
end
buffer = ''
until io.eof? do
buffer = io.read(10485760)
file.write(buffer)
end
I see that Ruby provides for a buffer and I'm wondering what the
reason is? I read this article but am still not clear on the benefit
of a buffer at all:
http://rcoder.net/content/fast-ruby-io
I'm wondering if providing a buffer might reduce malloc issues and
speed things up? I can't see any other reason to use one..
Thanks in advance for any information!
Steve