News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Efficient Use Of ReadFile API

Started by cman, May 25, 2010, 06:12:15 PM

Previous topic - Next topic

cman

I want to perform an algorithm on a set of characters contained in a file. Is it more efficient to use ReadFile to read characters in one at a time ( I'm guessing not ) or to try to read in as much of the file per use of ReadFile as possible ( or does it matter at all ? ). Thanks for any input!  :bg

dedndave

i always try to process about 32 Kb at a time if it's practical
in many cases, you have to save the end of one part and combine it with the next part so that the processing is contiguous

Tedd

Multiple calls to any function is always going to be less efficient than calling it once to get as much as you can.
If the file is small (less than 64kB) just read it all at once, otherwise read sizeable chunks at a time.
If your processing could overlap chunks, you can read a whole chunk, process 3/4 of it (or however much is appropriate), copy the remaining data to the start of the buffer, and then do another read to fill the rest of the buffer again.
No snowflake in an avalanche feels responsible.

hutch--

On any 32 bit box I would not go under 1 meg, bigger is better.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php