comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Performance of the Streams 'Read and 'Write
Date: Mon, 2 Nov 2009 15:37:48 -0600
Date: 2009-11-02T15:37:48-06:00	[thread overview]
Message-ID: <hcnjfd$it0$1@munin.nbi.dk> (raw)
In-Reply-To: 715d78f4-9b01-4598-88c1-6fc202983bae@p35g2000yqh.googlegroups.com

"Gautier write-only" <gautier_niouzes@hotmail.com> wrote in message 
news:715d78f4-9b01-4598-88c1-6fc202983bae@p35g2000yqh.googlegroups.com...
> On 30 Okt., 04:36, Georg Bauhaus <rm-host.bauh...@maps.futureapps.de>:
>
>> 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.
>
> Sure, it is the safe way: write records field by field, arrays element
> by element (that recursively). The compiler avoids problems with non-
> packed data. Nothing against that. The general case is well done,
> fine. But the compiler could have a look a the type left to the
> attribute and in such a case (an array of Unsigned_8, or a String)
> say: "Gee! that type Buffer is coincidentally the same as
> Stream_Element_Array, then I take the shortcut to generate the code to
> write the whole buffer and, this time, not the code to write it
> element by element".

IMHO, Ada compilers should do that. (There's specifically a permission to do 
this optimization in Ada 2005: 13.13.2(56/2).) That's an intergral part of 
the stream attribute implementation on Janus/Ada. (Disclaimer: the entire 
stream attribute implementation on Janus/Ada doesn't work right, quite 
probably because it is too complicated. So perhaps there is a reason that 
other Ada compilers don't do that. :-) Note, however, that it is pretty rare 
that you could actually do that (only about 15% of the composite types I've 
seen in Janus/Ada would qualify). So I'm not surprised that implementers 
have left that capability out in favor of things that happen more often.

                             Randy.





  reply	other threads:[~2009-11-02 21:37 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
2009-10-30  9:13   ` Gautier write-only
2009-11-02 21:37     ` Randy Brukardt [this message]
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