From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16154 invoked by alias); 27 Feb 2003 10:36:01 -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 16087 invoked by uid 71); 27 Feb 2003 10:36:01 -0000 Resent-Date: 27 Feb 2003 10:36:01 -0000 Resent-Message-ID: <20030227103601.16086.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, peturr02@ru.is Received: (qmail 15885 invoked by uid 48); 27 Feb 2003 10:34:44 -0000 Message-Id: <20030227103444.15884.qmail@sources.redhat.com> Date: Thu, 27 Feb 2003 10:36:00 -0000 From: peturr02@ru.is Reply-To: peturr02@ru.is To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: libstdc++/9876: filebuf::sputc more than 10% slower than putc X-SW-Source: 2003-02/txt/msg01411.txt.bz2 List-Id: >Number: 9876 >Category: libstdc++ >Synopsis: filebuf::sputc more than 10% slower than putc >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Thu Feb 27 10:36:01 UTC 2003 >Closed-Date: >Last-Modified: >Originator: peturr02@ru.is >Release: gcc-3.2.1 >Organization: >Environment: Red Hat Linux 8.0 >Description: filebuf::sputc is more than 10% slower than putc with these tests: time ./stdio 10.97user 1.60system 0:12.79elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (23major+9minor)pagefaults 0swaps time ./iostreams 12.56user 1.89system 0:14.66elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (80major+15minor)pagefaults 0swaps ****** speed.hh ****** #ifndef SPEED_HH_INCLUDED #define SPEED_HH_INCLUDED const int iterations = 100000000; #endif ****** stdio.cc ****** #include #include "speed.hh" int main() { using namespace std; FILE* file = fopen("tmp", "w+"); for (int i = 0; i < iterations; ++i) { putc(i % 100, file); } fclose(file); return 0; } ****** iostreams.cc ****** #include #include "speed.hh" int main() { using namespace std; filebuf buf; buf.open("tmp", ios_base::out | ios_base::in | ios_base::trunc); for (int i = 0; i < iterations; ++i) { buf.sputc(i % 100); } buf.close(); return 0; } >How-To-Repeat: >Fix: This speed difference disappears if streambuf::sputc is inlined and all the cruft deleted so it looks like: int_type sputc(char_type c) { if (pptr() < epptr()) { *pptr() = c; pbump(1); return traits_type::to_int_type(c); } else return overflow(traits_type::to_int_type(c)); } >Release-Note: >Audit-Trail: >Unformatted: