Page 1 of 1

Why would a program run faster the second time?

Posted: Tue May 03, 2011 1:47 pm
by Seymour Clufley
I've been writing a program which reads many dozens of files.

Running it from PB, I find that the first time I run the program (after restarting the computer), it takes a while to "warm up". But running it the second time, it's much faster.

Why would this be happening? Are recently-opened files held in RAM, or in the CPU cache?

Re: Why would a program run faster the second time?

Posted: Tue May 03, 2011 2:04 pm
by c4s
Seymour Clufley wrote:Are recently-opened files held in RAM, or in the CPU cache?
Yes, probably. Windows caches files etc. to some extent. Don't know enough about it though.

Re: Why would a program run faster the second time?

Posted: Tue May 03, 2011 2:24 pm
by MachineCode
Yep, the files are cached. Tip: When your app is first run, and is idle, do a background read of the files. Then when the user wants to read the files later, it'll be lightning fast. ;)