开发者

Duplicate file take different times to read

can anyone tell me why two files - duplicates of each other - take different times to load in memory?

var fileStream = new FileStream(filename,
                  FileMode.Open,
                  FileAccess.Read,
                  FileShare.Read,
                  16 *开发者_开发问答 1024,
                  FileOptions.SequentialScan);

It's this line that is slow (one file takes 3 times as long...)

fileStream.CopyTo(Form1.GlobalMS);

ODDLY, when I copy the file (in cmd window) and then try to load that file - it loads very fast... almost as if newly created files are somehow more accessible - could this be something to do with old files getting fragmented in someway? These are all 1G plus files by the way


Are they stored in different places (eg. one on a network share?)

How are you timing? Are you sure you're not forgetting to reset a timer, so the timing you get from the second one includes the first one?

Are you clearing any variables between the two tests to make sure the timing is fair?


Maybe you don't have enough memory to load the second file after you load the first file? So PC emulates RAM using HDD?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜