我只是想知道使用PLINQ/Parallel可以更快地平行File.Read
嗎?我的代碼如下所示(.NET 4.0):是並行File.Read快於順序讀取?
public static void ReadFileParallel(List<string> fileName)
{
Parallel.Foreach(fileName, file=>File.Read(file));
}
public static void ReadFilePLINQ(List<string> fileName)
{
fileName.AsParallel().foreach(file=>File.Read(file));
}
我問這個是因爲我認爲這個文件讀取IO束縛的原因,這樣做平行不會幫助,是嗎?
這些都是合理的標準。但在實踐中,我會說測量它而不是猜測。 – 2010-07-13 14:09:24