如何在 C# 中清空/刷新 Windows READ 磁盘缓存? [英] How to empty/flush Windows READ disk cache in C#?

查看:33
本文介绍了如何在 C# 中清空/刷新 Windows READ 磁盘缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想确定驱动器的读取速度,我可以编写一个例程将文件写入文件系统,然后读回这些文件.不幸的是,这并不能提供准确的读取速度,因为 Windows 会进行磁盘读取缓存.

If I am trying to determine the read speed of a drive, I can code a routine to write files to a filesystem and then read those files back. Unfortunately, this doesn't give an accurate read speed because Windows does disk read caching.

有没有办法在 C#/.Net(或者可能使用 Win32 API 调用)中刷新驱动器的磁盘读取缓存,以便我可以直接从驱动器读取文件而无需缓存它们?

Is there a way to flush the disk read cache of a drive in C# / .Net (or perhaps with Win32 API calls) so that I can read the files directly from the drive without them being cached?

推荐答案

为什么要DIY?

如果您只需要确定驱动器速度并且对学习如何从 .NET 刷新 I/O 缓冲区并不真正感兴趣,您可以使用 http://research.microsoft.com/barc/Sequential_IO/.它具有带有和不带有缓冲区刷新的随机/顺序模式.

If you only need to determine drive speed and not really interested in learning how to flush I/O buffers from .NET, you may just use DiskSpd utility from http://research.microsoft.com/barc/Sequential_IO/. It has random/sequential modes with and without buffer flushing.

该页面还有一些 I/O 相关的研究报告,您可能会觉得有用.

The page also has some I/O related research reports you might find useful.

这篇关于如何在 C# 中清空/刷新 Windows READ 磁盘缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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