NodeJS:fs.appendFile是否保持打开文件的链接,所以追加速度更快?

http://nodejs.org/api/fs.html#fs_fs_appendfile_filename_data_options_callback

fs.appendFile是否保持打开文件的链接,所以追加速度更快? (而不是打开/closures每个写入)

什么是写入CSV文件的最快方法? 我已经使用appendfile将新行写入CSV文件。 写入stream会更快吗? (如果appendfile每次打开文件)

注意:我实际上正在写约20GB的CSV

跟进:我可以确认createWriteStream比appendFile快得多

它看起来像fs.appendFile在完成写入每个块时closures文件。

https://github.com/joyent/node/blob/master/lib/fs.js#L907

所以一个stream可能会更快。 但是,如果您正在编写大量的CSV文件,它可能只会有所作为。

fs.appendFile是一个方便的function。

如果性能对你很重要,那么应该使用fs.createWriteStream来代替。