fwrite() - effect of size and count on performance

前端 未结 3 1530
忘了有多久
忘了有多久 2020-12-18 18:59

There seems to be a lot of confusion regarding the purpose of the two arguments \'size\' and \'count\' in fwrite(). I am trying to figure out which will be faster -

3条回答
  •  孤城傲影
    2020-12-18 19:19

    I'd like to point you to my question, which ended up exposing an interesting performance difference between calling fwrite once and calling fwrite multiple times to write a file "in chunks".

    My problem was that there's a bug in Microsoft's implementation of fwrite so files larger than 4GB cannot be written in one call (it hangs at fwrite). So I had to work around this by writing the file in chunks, calling fwrite in a loop until the data was completely written. I found that this latter method always returns faster than the single fwrite call.

    I'm in Windows 7 x64 with 32 GB of RAM, which makes write caching pretty aggressive.

提交回复
热议问题