如何查看硬盘速度
如何找到硬盘速度?我无法使用System.IO.File.Copy
并使用计时器来获取硬盘速度,因为缓存文件后,速度将真正高于实时速度。
我能做什么呢?
How can I find hard disk speed? I can not use System.IO.File.Copy
and use timer to get hard disk speed, because after caching file, the speed will be really higher than real time.
What can I do instead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
写入文件后后续读取速度远高于预期的原因是文件在写入时被操作系统缓存在磁盘系统缓存中,即内存中。随后的文件读取实际上是从内存而不是磁盘读取。
请参阅此代码项目文章,它提供了一种通过利用 FILE_FLAG_NO_BUFFERING 标志:
http://www.codeproject .com/KB/files/unbuffered.aspx
此解决方案可在您的上下文中使用,以避免操作系统磁盘缓存,从而获得“真实”磁盘速度。
The reason the subsequent read speed is much higher than expected after writing a file, is that the file is cached by the OS in the disk system cache when it is written i.e. in-memory. The subsequent file read is in effect being read from memory, rather than disk.
Please see this code project article which provides a solution for bypassing the OS disk cache by leveraging the FILE_FLAG_NO_BUFFERING flag:
http://www.codeproject.com/KB/files/unbuffered.aspx
This solution can be used in your context to avoid OS disk caching, and so obtain "real" disk speeds.
您问的是“实时”。由于在实际情况下正在使用缓存,因此我没有看到任何问题。您可能想使用一些脚本或类似的脚本来运行您的程序,而不是一些 File.Copy 或其他更简单的测试。
但真正的问题是,然后呢?即,您是否试图找出某个磁盘是否足够快,或者您是否试图找出您的程序是否足够快?
You are asking about "real time". Since in real case cache is in use, I don't see any problems. You might like to use some script or similar to run your program instead of some File.Copy or other simpler tests.
But the real question is, what then? I.e. are you trying to find out if some disk is fast enough or are you trying to find out if your program is fast enough?