How do you determine the optimal disk IO block size on Win32?

大憨熊 提交于 2020-01-04 13:31:10

问题


On Posix systems, the st_blksize member of the stat structure contains the optimal block size for IO for a given file. It looks like the Win32 implementations of stat (_stat & _stat64) do not support this field. What is the Win32 equivalent way of determining the optimal IO block size for a given file or filesystem?


回答1:


I'm not sure if this will always return the optimal number, but the Win32 call GetDiskFreeSpace returns, among other things, lpBytesPerSector and lpSectorsPerCluster; multiply those to get the bytes per cluster which is (perhaps) a reasonable value to use as a buffer size.

This call doesn't apply to files, but rather file systems, so you'd have to figure out what root the file lives on before using it.



来源:https://stackoverflow.com/questions/3478610/how-do-you-determine-the-optimal-disk-io-block-size-on-win32

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!