From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,68494635acddb77e X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!m73g2000hsh.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: File output and buffering Date: Wed, 20 Aug 2008 07:41:30 -0700 (PDT) Organization: http://groups.google.com Message-ID: <93cbe6e8-98f5-4e44-8eb3-c0e0e911f702@m73g2000hsh.googlegroups.com> References: <60a35fd4-e5a6-4aa0-a73f-6815ce7e92fc@f36g2000hsa.googlegroups.com> <4af2f934-7458-4370-b325-c38e3a4068b8@s50g2000hsb.googlegroups.com> <48ac19fc$0$11747$9b4e6d93@newsspool1.arcor-online.net> NNTP-Posting-Host: 128.141.45.203 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1219243290 3085 127.0.0.1 (20 Aug 2008 14:41:30 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 20 Aug 2008 14:41:30 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: m73g2000hsh.googlegroups.com; posting-host=128.141.45.203; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:1678 Date: 2008-08-20T07:41:30-07:00 List-Id: On 20 Sie, 15:19, Georg Bauhaus wrote: > Using the following stupid programs for comparison, > and using strace, I get 3370 calls to write(2) from C, > but 50_000 from both C++ and Ada. The C++ part can be explained by the fact that you did not use it properly. > =A0 =A0 =A0 =A0 std::cout << s << std::endl; Try this instead: std::cout << s << '\n'; The difference is that std::endl performs *two* actions on the given stream: it inserts the newline and... flushes. If you intend to only insert the newline character, do what you mean. It is even less typing. (yes, 99% of "benchmarks" available on the web are broken for the same reason) -- Maciej Sobczak * www.msobczak.com * www.inspirel.com Database Access Library for Ada: www.inspirel.com/soci-ada