How can I find hard disk speed

你离开我真会死。 提交于 2019-12-07 19:26:53

问题


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?


回答1:


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.




回答2:


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?



来源:https://stackoverflow.com/questions/3382547/how-can-i-find-hard-disk-speed

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