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,3a6a9f1d654285ba X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!c2g2000yqi.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Ada Shootout program for K-Nucleotide (patches) Date: Mon, 3 Aug 2009 13:47:16 -0700 (PDT) Organization: http://groups.google.com Message-ID: <49a11e4e-89e5-47b1-8a5f-a7e032107532@c2g2000yqi.googlegroups.com> References: <4a743343$0$32674$9b4e6d93@newsspool2.arcor-online.net> <0c18b36c-7af0-454c-8208-9b0416111a1f@w41g2000yqb.googlegroups.com> <87fxc9e0mg.fsf@nbi.dk> <4a76cd4f$0$31329$9b4e6d93@newsspool4.arcor-online.net> <87bpmxdqfo.fsf@nbi.dk> NNTP-Posting-Host: 94.108.158.61 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1249332445 20177 127.0.0.1 (3 Aug 2009 20:47:25 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 3 Aug 2009 20:47:25 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: c2g2000yqi.googlegroups.com; posting-host=94.108.158.61; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.11) Gecko/2009061208 Iceweasel/3.0.9 (Debian-3.0.9-1),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:7550 Date: 2009-08-03T13:47:16-07:00 List-Id: Isaac Gouy wrote on comp.lang.ada: > Jacob Sparre Andersen wrote: > > > Georg Bauhaus wrote: > > > Jacob Sparre Andersen schrieb: > > > > Wouldn't it be even faster to map the data file to a string (using > > > > POSIX.Memory_Mapping.Map_Memory), and then "read" from that > > > > string? > > > > According to the FAQ, "programs are expected to either take a single > > > command-line parameter or read text from stdin." > > > If we interpret this as the choice of the implementer, then there is > > no problem. =A0If the programs have to be able to read from stdin, then > > memory mapped files aren't of much use. > > "read line-by-line a redirected FASTA format file from stdin" > > http://shootout.alioth.debian.org/u32/benchmark.php?test=3Dknucleotide&..= . It is impossible to read line-by-line on Unix because Unix has no concept of a line. Instead, every program must read fixed-size chunks from the file (allowing for the possibility that a read returns fewer than the requested number of bytes) and interpret the bytes read to detect "end of lines" in ASCII text. The smallest chunk that can be read is one byte. Whether this is done inside the language's predefined library, in a third-party library or directly in a program is irrelevant; the mechanism is always the same. On the other hand, standard input is a stream of potentialy infinite length and it is impossible to map a stream in memory. That is why I suggested using Ada's stream facility instead of Ada.Text_IO. -- Ludovic Brenta.