One read vs. multiple sequential reads

Started by
1 comment, last by Promit 20 years, 3 months ago
I''ve seen two major patterns in loading files (files like BSP, MD2, etc.) One is to load each block of data sequentially. The other is to load the entire file at once and then use memory offsets to pull data from the file buffer. If you assume no fseeks in either method, which is generally going to perform better?
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Advertisement
Probably about the same, though I''m sure it''d depend on a number of factors. If they''re using a buffered file stream like fopen, it probably won''t be much different, unless the data blocks are big. In general, loading more data (up to a certain point) in one go is better, but it''s not all that deterministic without timings.

I like pie.
[sub]My spoon is too big.[/sub]
Depends on how the information is used, the block size in the first method, if the second method uses memory mapping, phase of the moon during compile, how buffering is performed, the underlying operating system, what kind of device the file is being pulled from, whether Mercury is in the third house at runtime, the total physical memory and page file size of the computer running the application, etc.

This topic is closed to new replies.

Advertisement