Why would a program run faster the second time?

For everything that's not in any way related to PureBasic. General chat etc...
Seymour Clufley
Addict
Addict
Posts: 1266
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Why would a program run faster the second time?

Post 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?
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

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

Post 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.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

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

Post 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. ;)
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
Post Reply