"ishekar" <is******@vsnl.net> wrote in message
news:c1**********@news.mch.sbs.de...
Hi,
I have an application where i want to write data to a file, the data is
being sent from an external source. I know the total size of the data and
then i retrieve the data in small segments from the source. This data is
written to file in a loop.
My question.
1. Will it be useful to increase the file size initially then seek to 0
and start writing to file. whether there will be any performance improvements
because of the allocation of the file earlier and due to less io? or this
doesnt matter because every fwrite writes to disk(OS may schedule writing
to disk).
2. If this is helps performance, do i have an api to initialise the file
with some size and empty strings?
TFI
ishekara.
The answer to this sort of question is always
1) Do it the simplest way first (in this case don't precreate the file).
2) Once the program is working to some profiling to see if the file I/O
speed is a problem or not. If not then you've saved yourself the bother of
writing the more complex code.
3) If it is a problem then try your alternate method, profile that and see
if it is any faster. Bear in mind that the results on one computer may not
be reflected on another computer.
There is no way in standard C++ of creating a file so big, except writing
out the required number of bytes. Your operating system may have a more
efficient way of doing this.
john