I am working on a server programming on linux machine using epoll. I am printing log statements using printf(), but I was wondering which output method uses the least system resources.
As you guys already know, server programming deals with a lot of log statements so I was wondering the best output method I should use. Possible candidates are printf cout etc..
Thanks in advance.
Both
printfandcoutare console output methods, neither is going to trouble your CPU greatly, you are probably worrying about nothing.However C++ provides three standard output streams –
cout,cerr, andclog. I suggest that you should use the latter since that is what it is for, and the output of your log is then system defined.If you do not need output formatting, then it will be marginally (and probably not measurably) faster to use
fwrite(),puts(), orclog.write()