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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,3a6a9f1d654285ba X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!g1g2000vbr.googlegroups.com!not-for-mail From: jonathan Newsgroups: comp.lang.ada Subject: Re: Ada Shootout program for K-Nucleotide (patches) Date: Wed, 19 Aug 2009 15:15:54 -0700 (PDT) Organization: http://groups.google.com Message-ID: <6f1c440c-9941-4aa7-a4cd-bf02a00db49a@g1g2000vbr.googlegroups.com> References: <4a743343$0$32674$9b4e6d93@newsspool2.arcor-online.net> <4bc4b12d-40f8-4140-8ef6-326d9e6b8adf@k30g2000yqf.googlegroups.com> <4a897b61$0$30221$9b4e6d93@newsspool1.arcor-online.net> <4d48b846-bb2d-4126-86c2-487b2244c9ad@d4g2000yqa.googlegroups.com> <4a8c119d$0$31866$9b4e6d93@newsspool3.arcor-online.net> <9b7557ca-df60-4d70-b692-f077b71983eb@g10g2000yqh.googlegroups.com> NNTP-Posting-Host: 143.117.23.233 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1250720154 16425 127.0.0.1 (19 Aug 2009 22:15:54 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 19 Aug 2009 22:15:54 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: g1g2000vbr.googlegroups.com; posting-host=143.117.23.233; posting-account=Jzt5lQoAAAB4PhTgRLOPGuTLd_K1LY-C User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.12) Gecko/2009072220 Iceweasel/3.0.6 (Debian-3.0.6-1),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:7887 Date: 2009-08-19T15:15:54-07:00 List-Id: On Aug 19, 7:24=A0pm, Robert A Duff wrote: > Martin writes: > > Isn't there something that could be done about the lines: > > > =A0 =A0 =A0 return Unbounded.To_String (Data_Buffer); > > =A0 =A0end Read; > > and > > =A0 =A0Buffer : constant String :=3D Read; > > > ...not sure what the answer is (don't have a compiler / debugger to > > hand just now but it just looks like there's a copy too many in there > > somewhere... > > > Also, is using "Ada.Text_IO.Get_Line" particularly fast? > > No. =A0Neither is Strings.Unbounded. =A0If you're trying to write fast co= de, > I would experiment with avoiding both. > > - Bob Ok, I finally put some print statements in to check. begin -- function Read: ada.text_io.put("1"); Skip_To_Section; ada.text_io.put("2"); Read_Section; ada.text_io.put("3"); Unbounded.Translate (Data_Buffer, Mapping =3D> Maps.Constants.Upper_Case_Map); ada.text_io.put("4"); return Unbounded.To_String (Data_Buffer); end Read; -- execute function Read: Buffer : constant String :=3D Read; ... begin -- execution of the program ada.text_io.put("5"); ... >From 1 to 2 takes 3.5 sec. It is reading 125 Meg of text line by line and discarding it. (Using Ada.Text_IO.Get_Line as the rules suggest.) >From 2 to 3 takes 3.5 sec. It is reading 125 Meg of text line by line and storing it. (Using Ada.Text_IO.Get_Line as the rules suggest.) >From 3 to 5 is well under 1 sec. From 4 to 5 is negligible. Full running time is 36 sec. Jonathan