On May 14, 6:40 pm, "Carl Daniel [VC++ MVP]"
<cpdaniel_remove_this_and_nos...@mvps.org.nospam> wrote:
Rahul wrote:
I want to know why is writing into multiple files slow. for the
single file also we are opening and closing it 400 times so why is
this running 80 seconds faster.
First try a simple test: Make your program create and close 400
files, writing nothing to each file. By your description, you'd
expect that to take 80 seconds. If it does, then you have your
answer: file creation is slow. If it doesn't, then you know that
there's something else different between the two configurations of
your program that accounts for the difference.
As a second experiment, you might try using CreateFile/WriteFile
instead of fopen/fwrite to see if that makes a difference.
The application behaves differently on different systems. on one
computer I saw the fopen time (total for all 400 files) varying from
20 seconds to 100 seconds on different run's, while on the other the
fopen time remained same but the fwrite time (total for all files)
changed from 80 to 140 seconds.
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
overhead. -- RFC 1925