comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm-host.bauhaus@maps.futureapps.de>
Subject: Re: Performance of the Streams 'Read and 'Write
Date: Fri, 30 Oct 2009 04:36:27 +0100
Date: 2009-10-30T04:36:27+01:00	[thread overview]
Message-ID: <4aea5f3b$0$6593$9b4e6d93@newsspool3.arcor-online.net> (raw)
In-Reply-To: <e93ea909-9b8e-44c6-a537-fd68ed47cbc4@z41g2000yqz.googlegroups.com>

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).



  parent reply	other threads:[~2009-10-30  3:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-29 23:29 Performance of the Streams 'Read and 'Write Gautier write-only
2009-10-30  0:39 ` Jeffrey R. Carter
2009-10-30  8:58   ` Gautier write-only
2009-10-30 19:12     ` Jeffrey R. Carter
2009-10-31 23:46       ` Gautier write-only
2009-11-01 21:38       ` Gautier write-only
2009-11-02 21:32       ` Randy Brukardt
2009-10-30  3:36 ` Georg Bauhaus [this message]
2009-10-30  9:13   ` Gautier write-only
2009-11-02 21:37     ` Randy Brukardt
2009-11-02 22:16       ` Gautier write-only
2009-10-30 13:40 ` Gautier write-only
2009-11-02 22:19   ` Gautier write-only
2009-11-17 12:57 ` Gautier write-only
2009-11-17 13:26   ` Ludovic Brenta
2009-11-17 20:19   ` Building GNAT on Windows (Was: Re: Performance of the Streams 'Read and 'Write) Tero Koskinen
2009-11-18 10:55     ` Gautier write-only
2009-11-26 13:23   ` Performance of the Streams 'Read and 'Write Gautier write-only
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox