Re: Why is my app faster when it runs the second tyme ???

From: Christopher Browne (cbbrowne_at_acm.org)
Date: 12/18/03


Date: 18 Dec 2003 21:43:58 GMT

Quoth juri <ichweissalles@t-online.de>:
> Hi all,
>
> i´m sure everybody of you noticed the following effect:
> When i run my app. , shut it down, run it again it is much faster. In
> my case, (i scan my harddisk and build a database) the first time it
> takes 2 minutes, then 1:30 , finally 1:15.
>
> Could someone explain me this behaviour and maybe tell me how to take
> advantage of it ?

This is probably a result of read (and, to lesser degree, write)
cacheing.

The first time you run the program, it has to be read off of disk.
The second time, it is already in memory.

The first time you run the program, the data that it is reading has to
be read off of disk. Again, the second time, it is already in memory.

It is a bit surprising that it is faster still the _third_ time...

-- 
(format nil "~S@~S" "cbbrowne" "cbbrowne.com")
http://www.ntlug.org/~cbbrowne/spiritual.html
"People who don't use computers are more sociable, reasonable, and ...
less twisted" -- Arthur Norman


Relevant Pages

  • Re: nice story [link]
    ... restore the two backups. ... The second time the affected tree was vast and the manual inspection ... The first time I put a new hard disk in and restored to that, ... But experience the first time gave me confidence. ...
    (uk.rec.sheds)
  • Re: Most memorable live performance
    ... and this still stands out in my memory as about the most intense ... but one that stands out for me is seeing Faust at the ... It was my second time at the Met, ... first time was a routine performance of Carmen, ...
    (rec.music.opera)
  • RE: [SLE] OO: If you can make it, I can break it!
    ... any file read from disk is cached the first time it is loaded. ... developer;-) Once in cache it stays there unless the memory is needed ... > the memory hits. ...
    (SuSE)
  • RE: Memory Error
    ... first time it shows the follwoing error message ... If you get Memory Cannot be read or written. ... Under General Tab clear your History, Internet Files and Cookies. ... You may have a bad RAM try to test your RAM by running Memtest by ...
    (microsoft.public.windowsxp.general)
  • File System Performance Tuning
    ... the first time has a performance of 10.7MBps ... through, all the file data are cached in file cache, after that all ... memory map method deteriorate so much, ... setting this will make ReadFile method to do ...
    (microsoft.public.windowsce.platbuilder)