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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,d4226ffde2290b0c X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!newsfeeder.ewetel.de!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Fri, 30 Oct 2009 04:36:27 +0100 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.4pre) Gecko/20090915 Thunderbird/3.0b4 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Performance of the Streams 'Read and 'Write References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4aea5f3b$0$6593$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 30 Oct 2009 04:36:27 CET NNTP-Posting-Host: bf7e0108.newsspool3.arcor-online.net X-Trace: DXC=n3V_ho6IlHg>jlK2>IgHGdMcF=Q^Z^V3h4Fo<]lROoRa8kFejVhSg@R<7F;\ZdX62LWk<\I3e X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:8870 Date: 2009-10-30T04:36:27+01:00 List-Id: On 10/30/09 12:29 AM, Gautier write-only wrote: > procedure Write( b: in Buffer ) is > use Ada.Streams; > First : constant Stream_Element_Offset:= Stream_Element_Offset > (b'First); > Last : constant Stream_Element_Offset:= Stream_Element_Offset > (b'Last); > SE_Buffer : Stream_Element_Array (First..Last); > begin > for i in SE_Buffer'Range loop > SE_Buffer(i):= Stream_Element(b(Natural(i))); > end loop; > Write(Stream(f_out).all, SE_Buffer); > end Write; > > Naively, you would say it is even slower: you do even more by copying > a buffer into another one, right ? > Indeed, not at all, it is *lots* faster (on GNAT and ObjectAda)! I finally thought that the above procedures are faster than 'Read or 'Write because the latter are defined in terms of stream elements: When there is a composite object like b : Buffer and you 'Write it, then for each component of b the corresponding 'Write is called. This then writes stream elements, probably calling Stream_IO.Write or some such in the end. So Write from above appears closer to writing bulk loads of stream elements than a bulk load of 'Writes can be. Copying buffers does not matter in comparison to the needs of I/O (on PCs).