why is fprintf(stderr,) slow?
Eric Black
eric at chronon.UUCP
Sat Aug 30 03:49:51 AEST 1986
In article <7074 at utzoo.UUCP> henry at utzoo.UUCP (Henry Spencer) writes:
>> > Standard error is unbuffered, eg, one char at a time, so it makes one
>> > write system call per character, hence its slowness.
>> Surely you mean "per call".
>It *ought* to be "per call". On many systems, in *fact* it is "per character".
Of course, the reason that it was made per character is to make sure that
the error output in fact gets out, and is not lost in stdio buffering somewhere
when an errant program suddenly gives up the ghost. On BSD systems,
at least, you can change this with the setlinebuf(3S) call, to make
stderr use buffering. Nowadays, with buffered stdio output less likely
to get lost (?), perhaps it is too bad that the default is still
to make a system call per character, rather than per call, but...
On non-BSD systems you're stuck, as far as I know.
--
Eric Black "Garbage In, Gospel Out"
UUCP: {sun,pyramid,hplabs,amdcad}!chronon!eric
More information about the Comp.unix
mailing list