incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Sebor (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (STDCXX-7) std::operator<<(ostream&, const char*) inefficient for unbuffered file I/O
Date Mon, 11 Dec 2006 20:53:21 GMT
     [ http://issues.apache.org/jira/browse/STDCXX-7?page=all ]

Martin Sebor resolved STDCXX-7.
-------------------------------

    Resolution: Fixed

Running the program after applying the referenced patch shows just a single call to write(1):
$ truss -t write ./t
abcdef
write(3, " a b c d e f\n", 7)                   = 7


> std::operator<<(ostream&, const char*) inefficient for unbuffered file I/O
> --------------------------------------------------------------------------
>
>                 Key: STDCXX-7
>                 URL: http://issues.apache.org/jira/browse/STDCXX-7
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 27. Input/Output
>    Affects Versions: 4.1.2
>         Environment: All.
>            Reporter: Martin Sebor
>         Assigned To: Martin Sebor
>             Fix For: 4.2
>
>
> operator<<(ostream&, const char*) is inefficient when the stream argument is
an unbuffered fstream object: it causes a call to write() for each character  (ditto for the
wide character versions). This affects all platforms. Here's a test case with HP aCC:
> $ cat t.cpp && nice gmake SRCS=t.cpp && truss -o truss.out ./t &&
grep write truss.out
> #include <fstream>
> int main ()
> {
>     std::ofstream f ("/dev/tty");
>     f.rdbuf ()->pubsetbuf (0, 0);
>     f << "abcdef\n";
> }
> aCC -c -I/build/sebor/dev/stdlib/include/ansi -I/usr/include  -D_RWSTDDEBUG   -mt -D_RWSTD_USE_CONFIG
-I/build/sebor/aCC-3.63-15s/include -I/build/sebor/dev/stdlib/include -I/build/sebor/dev/stdlib/examples/include
 -Aa +nostl  -g +d  +w +W392 +W655 +W684 +W818 +W819 +W849  t.cpp 
> aCC t.o -o t -Aa +nostl -Wl,+s -Wl,+vnocompatwarnings -L/build/sebor/aCC-3.63-15s/lib
  -mt  -L/build/sebor/aCC-3.63-15s/lib -lstd15s  -lm  
> abcdef
> write(4, "a ", 1)                                          = 1
> write(4, "b ", 1)                                          = 1
> write(4, "c ", 1)                                          = 1
> write(4, "d ", 1)                                          = 1
> write(4, "e ", 1)                                          = 1
> write(4, "f ", 1)                                          = 1
> write(4, "\n", 1)                                          = 1

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message