| re: writing to file
ishekar wrote:
[color=blue]
> 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).[/color]
This is very platform specific, so you might want to ask in a newsgroup
about your OS. I think that usually, the performance when writing is
better, since the kernel doesn't need to search for free clusters on
the disk. But of course, creating the file initially will take time,
too. So if you need your hard drive to be as fast as possible so you
can keep up with a high data rate, it's probably a good idea to create
the file initially. If not, you won't probably gain anything or even
make the total run time worse due to the additional "initialization" of
the file.
[color=blue]
> 2. If this is helps performance, do i have an api to initialise the
> file with some size and empty strings?[/color]
Exept for just writing it yourself (which is actually very simple),
there is none in standard C++. |