gpt4 book ai didi

C# 文件流 : Optimal buffer size for writing large files?

转载 作者:IT王子 更新时间:2023-10-29 03:41:55 24 4
gpt4 key购买 nike

假设我正在将几个文件写入磁盘,大小在 2MB 到 5GB 之间。FileStream 的合理缓冲区值是多少?

使用几兆字节的缓冲区大小是否明智,还是我应该坚持使用千字节缓冲区?

最佳答案

默认缓冲区大小为 4 KiB。

另外,请看这里:Sequential File Programming Patterns and Performance with .NET

Programming patterns for sequential file access in the .NET Frameworkare described and the performance is measured. The default behaviorprovides excellent performance on a single disk – 50 MBps both readingand writing. Using large request sizes and doing file pre-allocationwhen possible have quantifiable benefits. When one considers diskarrays, .NET unbuffered IO delivers 800 MBps on a 16-disk array, butbuffered IO delivers about 12% of that performance. Consequently,high-performance file and database utilities are still forced to useunbuffered IO for maximum sequential performance. The report isaccompanied by downloadable source code that demonstrates the conceptsand code that was used to obtain these measurements.

关于C# 文件流 : Optimal buffer size for writing large files?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1862982/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com