From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6739 invoked by alias); 23 Mar 2003 19:46:04 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 6634 invoked by uid 71); 23 Mar 2003 19:46:01 -0000 Date: Sun, 23 Mar 2003 19:46:00 -0000 Message-ID: <20030323194601.6630.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: =?iso-8859-1?Q?P=E9tur_Run=F3lfsson?= Subject: RE: libstdc++/9876: filebuf::sputc more than 10% slower than putc Reply-To: =?iso-8859-1?Q?P=E9tur_Run=F3lfsson?= X-SW-Source: 2003-03/txt/msg01538.txt.bz2 List-Id: The following reply was made to PR libstdc++/9876; it has been noted by GNATS. From: =?iso-8859-1?Q?P=E9tur_Run=F3lfsson?= To: "Paolo Carlini" Cc: , , , Subject: RE: libstdc++/9876: filebuf::sputc more than 10% slower than putc Date: Sun, 23 Mar 2003 19:38:00 -0000 > Needless to say, you are right, and Nathan is right, about the need to > improve our streambuf::sputc, but we still do _not_ have real numbers > to use as a point of reference. >=20 > Are you willing to work on this? This is stdio vs. unlocked_stdio vs. iostreams: time ./stdio 1.11user 0.15system 0:01.27elapsed 99%CPU (0avgtext+0avgdata = 0maxresident)k 0inputs+0outputs (22major+8minor)pagefaults 0swaps time ./stdio_unlocked 0.28user 0.15system 0:00.43elapsed 99%CPU (0avgtext+0avgdata = 0maxresident)k 0inputs+0outputs (22major+8minor)pagefaults 0swaps time ./iostreams 1.00user 0.19system 0:01.20elapsed 99%CPU (0avgtext+0avgdata = 0maxresident)k 0inputs+0outputs (61major+15minor)pagefaults 0swaps This is on a Intel Pentium III 500 MHz with 384 MB ram, Red Hat Linux = 8.0 with kernel 2.5.44. This is the code: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D speed.hh = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D #ifndef SPEED_HH_INCLUDED #define SPEED_HH_INCLUDED const int iterations =3D 10000000; #endif =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D stdio.cc = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D #include #include "speed.hh" int main() { using namespace std; FILE* file =3D fopen("tmp", "w+"); for (int i =3D 0; i < iterations; ++i) { putc(i % 100, file); } fclose(file); return 0; } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D stdio_unlocked.cc = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D #include #include "speed.hh" int main() { using namespace std; FILE* file =3D fopen("tmp", "w+"); for (int i =3D 0; i < iterations; ++i) { putc_unlocked(i % 100, file); } fclose(file); return 0; } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D iostreams.cc = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D #include #include "speed.hh" int main() { using namespace std; filebuf buf; buf.open("tmp", ios::out | ios::in | ios::trunc); for (int i =3D 0; i < iterations; ++i) { buf.sputc(i % 100); } buf.close(); return 0; } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D There are also major differences in fwrite vs. filebuf::sputn when the buffer is bigger than BUFSIZ (fwrite doesn't copy the buffer when it is larger than BUFSIZ), as well as in putwc vs. wfilebuf::sputc (I think that codecvt is causing this slowdown). Petur