我正在写一个需要读取相当大的文件的应用程序。我一直想知道现代Windows XP计算机上读取缓冲区的最佳大小。我搜索了一下,发现了很多例子,其中最佳尺寸为1024。最佳文件缓冲区读取大小?
这里是我的意思的一个片段:
long pointer = 0;
buffer = new byte[1024]; // What's a good size here ?
while (pointer < input.Length)
{
pointer += input.Read(buffer, 0, buffer.Length);
}
我的应用程序是相当简单的,所以我不打算写任何基准测试代码,但想知道什么大小适用?
可能会有所帮助:http://stackoverflow.com/questions/19558435/what-is-the-best-buffer-size-when-using-binaryreader-to-read-big-files-1gb/19837238? noredirect = 1#19837238 – 2013-11-07 13:34:09