.NET 4.0内存映射文件的性能内存、性能、文件、NET

2023-09-07 15:37:39 作者:回眸丶忆红颜

我想知道是否有人尝试新的.NET 4.0内存映射文件的功能? 我知道他们是一样古老的操作系统,但本地处理的.NET是新的。

I'd like to know if anyone tried new .NET 4.0 Memory Mapped Files features? I know that they are as old as OS but native handling in .NET is new.

有没有人能够测试该说些什么表现? 我在访问时间为二进制文件,写入速度等随机配件很感兴趣。同样表现comparsion为本地WinAPI的MMF将是很好的。

Has anyone been able to test this and say something about performance? I'm quite interested in access time to random parts of binary file, write speed and so on. Also performance comparsion to native WinAPI MMF would be nice.

谢谢!

推荐答案

在.NET 4.0(在新 System.IO.MemoryMappedFiles 命名空间)内存映射文件简单地包裹在Win32 API的内存映射文件。

Memory mapped files in .NET 4.0 (in the new System.IO.MemoryMappedFiles namespace) simply wrap the Win32 API for memory mapped files.

这意味着他们以最快的速度是可能的。这是用来加载.NET程序到内存中相同的机制。

That means they are as fast as is possible. This is the same mechanism that is used to load .NET assemblies into memory.

在实际的时间数量而言,这将取决于32位与64位,您有多少内存,文件有多大,访问模式(S),并在很大程度上物理磁盘硬件的类型。

In terms of actual timing numbers, this will depend on 32bit versus 64bit, how much memory you have, how large the files are, the access pattern(s) and to a large extent the type of physical disk hardware.

参考:内存映射文件