Article View: comp.unix.programmer
Article #3467Re: Big performance problems with C++ file I/O
From: Stefaan A Eeckels
Date: Sat, 17 Apr 2004 23:31
Date: Sat, 17 Apr 2004 23:31
39 lines
2239 bytes
2239 bytes
On Sun, 18 Apr 2004 00:36:41 +0200 Aaron Isotton <aaron@isotton.com> wrote: > I am writing an application reading big text files (hundreds of > megabytes) line by line. I was reading the files using std::getline and > I noticed that it is *incredibly* slow. So I wrote three test programs, > one using fgets(), one using std::getline() and one using > std::ifstream::getline(). I have read the same file (200000 lines, 39MB) > Results with Sun's C/C++ Forte 6.2 compilers on a dual processor Ultra60/360 with Solaris8 (options -fast -O): ultra~/Stuff/iotest[195] time ./stdio 0.71u 0.14s 0:01.00 85.0% ultra~/Stuff/iotest[196] time ./streams 5.49u 0.23s 0:06.10 93.7% ultra~/Stuff/iotest[197] time ./streams2 3.85u 0.18s 0:04.17 96.6% With gcc 2.95.2: ultra~/Stuff/iotest[203] time ./stdio 0.72u 0.18s 0:00.93 96.7% ultra~/Stuff/iotest[204] time ./streams 16.96u 0.16s 0:18.33 93.3% ultra~/Stuff/iotest[205] time ./streams2 0.74u 0.16s 0:00.97 92.7% The slow execution of "streams" seems to be a gcc bug. Interestingly, the streams2 program is much faster when compiled with gcc. Take care, -- Stefaan -- "What is stated clearly conceives easily." -- Inspired sales droid
Technical Details
Message-ID:
<20040418013129.2e263fea.tengo@DELETEMEecc.lu>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!news.vo.lu!justus.ecc.lu!nobodyReferences:
<o4o8l1-4em.ln1@tiger.berg21.ch>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc89c,78838ebea02c7742 X-Google-Attributes: gidfc89c,public X-Google-Thread: f65d0,78838ebea02c7742 X-Google-Attributes: gidf65d0,public X-Google-ArrivalTime: 2004-04-18 00:00:04 PST Date: Sun, 18 Apr 2004 01:31:29 +0200 From: Stefaan A Eeckels <tengo@DELETEMEecc.lu> Newsgroups: comp.unix.programmer,gnu.gcc Subject: Re: Big performance problems with C++ file I/O Message-ID: <20040418013129.2e263fea.tengo@DELETEMEecc.lu> References: <o4o8l1-4em.ln1@tiger.berg21.ch> Organization: E.C.C. sa - Computer Consultants X-Newsreader: Sylpheed version 0.9.10cvs7 (GTK+ 1.2.7; sparc-sun-solaris2.8) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit NNTP-Posting-Host: pppoe58-luxdsl-092.pt.lu X-Trace: news.vo.lu 1082271603 213.166.58.92 (18 Apr 2004 09:00:03 +0200) Lines: 39 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!news.vo.lu!justus.ecc.lu!nobody