The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: bert35 on March 26, 2011, 03:22:31 PM

Title: execution time of masm32 program
Post by: bert35 on March 26, 2011, 03:22:31 PM
I am new to masm32 and I am studying the examples in the \masm32\examples\ folder. The example findfile, which is in  masm32\examples\exampl05\findfile\ must be executed as findfile <filename>. When this is done right after Windows start up it takes about 70 seconds. When I repeat the same findfile<filename> it only takes 3 seconds. So only the first execution takes 70 seconds. Can somebody give an explanation?   My system is Windows XP SP3. 
Title: Re: execution time of masm32 program
Post by: Tedd on March 26, 2011, 03:37:13 PM
When you open a folder, the OS obtains a list of the files in that folder. It caches this list so it can be obtained quickly next time. On startup, many paths have not been opened yet, so they are missing from this cache. The first time you run your program, the paths accessed are added to the cache. The next times you run it, they're already in the cache and so it runs much quicker.
Title: Re: execution time of masm32 program
Post by: bert35 on March 27, 2011, 01:35:36 PM
I wondered what would happen if, after the first execution, I would rename or delete one of the found files. It appeared that the list in the cache is then updated accordingly.
Title: Re: execution time of masm32 program
Post by: clive on March 27, 2011, 04:25:03 PM
The media onto which the file systems structures are written is the thing being cached. The file you renamed represents a very small fraction of the total data and structures cached.
Title: Re: execution time of masm32 program
Post by: Tedd on March 27, 2011, 08:38:15 PM
The cache is still kept in synch - when you make a change, it's changed first in the cache; the actual disk structures are updated 'later' (in the background, whenever it's convenient for the OS.)