问题
I'm about to choose using FlushFileBuffers after each write in a file or FILE_FLAG_NO_BUFFFERING each time I need open the same file.
But I did not find any performance comparison table about the use of one or another option. Well, except this advice in MSDN:
If an application is performing multiple writes to disk and also needs to ensure critical data is written to persistent media, the application should use unbuffered I/O instead of frequently calling FlushFileBuffers. To open a file for unbuffered I/O, call the CreateFile function with the FILE_FLAG_NO_BUFFERING and FILE_FLAG_WRITE_THROUGH flags. This prevents the file contents from being cached and flushes the metadata to disk with each write.
So I'm assuming that: for an application that will write and read many times it is better not use FlushFileBuffers. But there is any comparison article, blog, forum post about the use of them? And if the file is being closed after the write? My google-fu did not get anything yet.
来源:https://stackoverflow.com/questions/10564575/there-is-a-comparison-or-performance-table-of-the-different-uses-of-flushfilebuf