stdio performance in tango, stdlib, and perl
Andrei Alexandrescu (See Website For Email)
SeeWebsiteForEmail at erdani.org
Sat Mar 24 18:38:06 PDT 2007
James Dennett wrote:
> As you appear to be saying that printf has to flush every
> time it's used, I'd guess that it's unusable for performance
> reasons alone.
Numbers clearly tell the above is wrong. Here's the thing: I write
programs that write lines to files. If I use cout, they don't work. If I
use fprintf, the do work, and 10 times faster. And that's that.
> It's also really hard to implement such a
> guarantee on most platforms without using some kind of
> process-shared mutex, file lock, or similar. Does printf
> really incur that kind of overhead every time something is
> written to a stream, or does its implementation make use
> of platform-specific knowledge on which writes are atomic
> at the OS level?
The C standard library takes care of it without me having to do anything
in particular.
> Within a process, this level of safety could be achieved
> with only a little (usually redundant) synchronization.
> Which is useful for debugging or simplistic logging,but
> not for anything else I've seen.
I do not concur.
Andrei
More information about the Digitalmars-d
mailing list