This site is no longer active and is available for archival purposes only. Registration and login is disabled.

High speed file access


High speed file access

Postby Erik Coenders » Jan 11, 2002 @ 4:55am

Hi,<br><br>I am preparing to write an application. Which file access method is the most advisable for the application? It reads continuously some files (100KB to 6MB) from file system at high speed. It is very important to use the physical memory as less as possible. Are memory-mapped files fast enough? Virtual memory?<br><br>Thanks in advance,<br><br>Erik<br>
Erik Coenders
 


Re: High speed file access

Postby MirekCz » Jan 11, 2002 @ 2:27pm

memory mapped files aren't any good as they need to be in memory in the first place, what you need is:<br>1.keep your stuff together, best would be to keep it in one file if possible<br>2.read as much data as possible with one fread/whatever function. On a PC my test show that on a quite fast hd(7200rpm udma66 ibm) increasing the reading block size by 4 times (so like 64kb instead 16kb) increases the time needed for this operation only by 2. So a huge gain. Also if you're reading from "random" positions in files it's better to read from start to end then to jump all over the file (sort the positions you need to access first and then access them)<br><br>This helps you about harddisk access, if you use a flash memory card or so the transfer speed should be much larger and therefore it shouldn't be a problem to load the amount of data you need in well under a second. (if interested in future chat, specify how long it can take for the program to load data and what kind of data you read)<br><br>and about how I do it, I use something like this:<br>FILE *tgafile;<br>if (!(tgafile = _tfopen(fullname, _T("rb"))))<br>{<br>//handle error here<br>}<br>//our great fread<br>fread(&bpp,1,1,tgafile);<br>...<br>//close the file<br>fclose(tgafile);<br><br>don't know if it's the best method but I guess it's one of the fastest
With best regards,
Mirek Czerwinski
User avatar
MirekCz
pm Member
 
Posts: 269
Joined: Sep 18, 2001 @ 6:42pm
Location: Poland,city Poznań


Return to Phantom's Forum


Sort


Forum Description

Discuss any of Phantom's projects here (Operation Nutcracker, etc.)

Moderators:

sponge, RICoder, Phantom

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum