🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #2023

cout vs printf speed (was: Should I learn C or C++ first?)

#2023
From: lemahieu
Date: Tue, 29 Aug 1995 20:21
26 lines
1973 bytes
dwalker@imtn.dsccc.com (Darren Walker) wrote:
[snip]
>
>the whole point is that you don't HAVE to use new and delete, they are merely
>_convenient_ overloadable operators, just like you may not want to use cout
>or cin for favor of a faster printf or fprintf. But like any feature, unless
>you use it, you have no idea how nice it really is...
[snip]
>--
>-------------------------------------------------------------------------------
>Darren Walker		    DSC Communications Corporation
>dwalker@imtn.tpd.dsccc.com  Plano, Tx
>-------------------------------------------------------------------------------

I was under the impression that cout and cin for I/O was actually _faster_
than using printf.  I thought this was because printf must parse
the format string each time to determine how the subsequent parameters
are to be interpreted and output, whereas this is done at compile time
for cout.  The format string is typically constant but must be reparsed every
time the printf function is called, which doesn't sound very efficient to me.
What is the logical argument for printf being faster?

If anyone has any numbers on stream I/O vs printf, I'd be interested in
hearing them.

--Paul
Technical Details
Message-ID: <41vst0$9nb@gap.cco.caltech.edu>
Path: arc1-ca.pugleaf.net!nntp-server.caltech.edu!news
References: <DDJ2Lp.3DG@pentagon-ai.army.mil> <41afe9$d10@newsbf02.news.aol.com> <41kici$p4t@deyke3.fc.hp.com> <41ngln$qau@druid.borland.com> <41tjep$2hn@deyke3.fc.hp.com> <41v8k9$jq8@tpd.dsccc.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!nntp-server.caltech.edu!news
From: <lemahieu@paradise.caltech.edu>
Newsgroups: rec.games.programmer,comp.lang.c++
Subject: cout vs printf speed (was: Should I learn C or C++ first?)
Date: 29 Aug 1995 20:21:52 GMT
Organization: California Institute of Technology, Pasadena
Message-ID: <41vst0$9nb@gap.cco.caltech.edu>
References: <DDJ2Lp.3DG@pentagon-ai.army.mil> <41afe9$d10@newsbf02.news.aol.com> <41kici$p4t@deyke3.fc.hp.com> <41ngln$qau@druid.borland.com> <41tjep$2hn@deyke3.fc.hp.com> <41v8k9$jq8@tpd.dsccc.com>
NNTP-Posting-Host: dali.paradise.caltech.edu
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 1.1N (X11; I; AIX 2)
X-URL: news:41v8k9$jq8@tpd.dsccc.com