I'm currently calling write() a lot which results in poor performances.
You need to do buffering as systems calls are expensive compared to "normal" operations.
You could simply use the standard library - get a
FILE *
and callfwrite
- this will automatically do bufferingYou could to your own buffering by appending to a buffer, using
mempcy
and friends. When the buffer fills you could simply do a largewrite
I would first try the stdio
approach as it's easier. If you're wondering how to get a FILE *
from a file descriptor, look for the POSIX-standard fdopen
.