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!news3.google.com!proxad.net!feeder1-2.proxad.net!news.in2p3.fr!in2p3.fr!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Performance of the Streams 'Read and 'Write Date: Mon, 2 Nov 2009 15:37:48 -0600 Organization: Jacob Sparre Andersen Message-ID: References: <4aea5f3b$0$6593$9b4e6d93@newsspool3.arcor-online.net> <715d78f4-9b01-4598-88c1-6fc202983bae@p35g2000yqh.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1257197869 19360 69.95.181.76 (2 Nov 2009 21:37:49 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Mon, 2 Nov 2009 21:37:49 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Xref: g2news2.google.com comp.lang.ada:8945 Date: 2009-11-02T15:37:48-06:00 List-Id: "Gautier write-only" wrote in message news:715d78f4-9b01-4598-88c1-6fc202983bae@p35g2000yqh.googlegroups.com... > On 30 Okt., 04:36, Georg Bauhaus : > >> 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.