Use an in-memory buffer. 4K is a good default size. Instead of invoking the write syscall for every single byte, you fill your buffer, then invoke the syscall just once and write the whole chunk at the same time. Then you can clear the buffer and do it again until EOF.
Top comments (3)
Use an in-memory buffer. 4K is a good default size. Instead of invoking the write syscall for every single byte, you fill your buffer, then invoke the syscall just once and write the whole chunk at the same time. Then you can clear the buffer and do it again until EOF.
Thanks.It's a good idea.I'm going to try memory buffer.
Welcome.