3 ms·
Some side notes: - The readFileSync in this benchmark has UTF-8 decoding (produces a string instead of a Buffer). That’s why it’s slower; not sure why it’s inc
by minitech 6y ago
Some side notes:
- The readFileSync in this benchmark has UTF-8 decoding (produces a string instead of a Buffer). That’s why it’s slower; not sure why it’s included.
- The first guess/suggestion,
> I suspect the cause is right here: [https://github.com/nodejs/node/blob/3b2863db12818778671713b5c30363f788912aae/lib/internal/fs/promises.js#L319-L339 https://github.com/nodejs/node/blob/3b2863db12818778671713b5...]
> Instead of creating a new Buffer for each chunk, it could allocate a single Buffer and write to that buffer. I don't think Buffer.concat or temporary arrays are necessary.
is already what the code does. Multiple chunks and Buffer.concat are only involved if more data gets read than stat initially reports.
- KoenDG 6y ago>The readFileSync in this benchmark has UTF-8 decoding Do you have benchmark results to show this?