在 Win32 上如何确定最佳磁盘 IO 块大小? [英] How do you determine the optimal disk IO block size on Win32?

查看:33
本文介绍了在 Win32 上如何确定最佳磁盘 IO 块大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Posix 系统上,stat 结构的 st_blksize 成员包含给定文件的 IO 的最佳块大小.看起来 stat (_stat & _stat64) 的 Win32 实现不支持此字段.确定给定文件或文件系统的最佳 IO 块大小的 Win32 等效方法是什么?

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?

推荐答案

我不确定这是否会始终返回最佳数字,但 Win32 调用 GetDiskFreeSpace 会返回,其中包括 <代码>lpBytesPerSector 和 lpSectorsPerCluster;将它们相乘以获得每个簇的字节数,这(可能)是用作缓冲区大小的合理值.

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.

这篇关于在 Win32 上如何确定最佳磁盘 IO 块大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆