Why the fwrite libc function is faster than the syscall write function?

后端 未结 3 1840
Happy的楠姐
Happy的楠姐 2021-02-05 05:08

After providing the same program which reads a random generated input file and echoes the same string it read to an output. The only difference is that on one side I\'m providin

3条回答
  •  南旧
    南旧 (楼主)
    2021-02-05 05:10

    You can also disable buffering with setbuf() function. When the buffering is disabled, fwrite() will be as slow as write() if not slower.

    More information on this subject can be found there: http://www.gnu.org/s/libc/manual/html_node/Controlling-Buffering.html

提交回复
热议问题