(no title)
sehrope | 11 years ago
fs.readFile(...) reads the entire contents of the file into memory. For small files that may be acceptable but if you're dealing with anything that could be large it's not going to be very pleasant or even work properly.
I just tried it out on my laptop for a 100MB and a 1GB file. For a 100MB file using streams is about 25% slower. However the sync method failed for the 1GB file:
Style 100MB 1GB
===== ===== ===
fs.readFileSync .176s <failed>
streams/pipe .234s 1.25s
hoggle|11 years ago
Default buffer size seems to be 64k: https://github.com/joyent/node/blob/912b5e05811fd24f09f9d652...
Stream buffering: http://www.nodejs.org/api/stream.html#stream_buffering