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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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-7-bit Path: g2news2.google.com!news4.google.com!feeder.news-service.com!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Wed, 05 Aug 2009 23:18:09 +0200 From: Georg Bauhaus Reply-To: rm.tsoh+bauhaus@maps.futureapps.de User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada Shootout program for K-Nucleotide (patches) 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> <2bae762e-0d8a-4389-843a-466e87f59fd1@a37g2000prf.googlegroups.com> <4a786b15$0$30230$9b4e6d93@newsspool1.arcor-online.net> <67e76046-62d4-4c0e-bdd8-8d00cdf93bca@l35g2000pra.googlegroups.com> In-Reply-To: <67e76046-62d4-4c0e-bdd8-8d00cdf93bca@l35g2000pra.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <4a79f712$0$31874$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 05 Aug 2009 23:18:10 CEST NNTP-Posting-Host: 81564941.newsspool3.arcor-online.net X-Trace: DXC=?U6;bdbdS?M0YMcF=Q^Z^V3X4Fo<]lROoRQ^YC2XCjHcbYhDYha2KL_]\A:ho7QcPOVSOUijKh?@5:XC`N>C5Ia>WR X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:7612 Date: 2009-08-05T23:18:10+02:00 List-Id: Isaac Gouy wrote: > On Aug 4, 10:08 am, Georg Bauhaus > wrote: >> Isaac Gouy schrieb: >> >> >> >>> On Aug 4, 8:43 am, Isaac Gouy wrote: >>>> On Aug 3, 1:29 pm, Robert A Duff wrote: >>>>> Isaac Gouy writes: >>>>>> On Aug 3, 5:36 am, Jacob Sparre Andersen wrote: >>>>>>> If we interpret this as the choice of the implementer, then there is >>>>>>> no problem. If 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=knucleotide&... >>>>> What exactly does that mean? >>>>> Would it be "cheating" to read all of stdin until reaching end-of-file, >>>>> and then break the result up into lines (by whatever means)? >>>> iirc the default buffer size for Java reader is 8192 bytes - use that. >>> Better yet, the C++ programn seems to do just fine with this: >>> char buffer[128]; >> But the more pressing question is, to me at least---others >> will have better ideas---what functionality may we use for >> reading, say, 128 char values? Can we import OS functions? >> Or the POSIX library? I have already install libflorist in >> a new testing VM, in order to compare Text_IO agains POSIX >> input. > > > And was that an improvement? Yes. Using GNAT's binding to C streams improves running time of fasta 25000000 from ~14s to ~10s on Ubuntu 9.04 64bit running in VMware. ($ time ./fasta 25000000 > /dev/null) The result is even more noticeable when either version's output is redirected into a fresh (new) file on disk. (~42s versus ~20s). Using Florist should end up making similar calls, so I expect similar improvements (TBD, soon). The change is small (to fasta #1 as is): 1 - Add a small Print procedure that takes an Ada string, copies it into a C string with \n and \0, and sends that to fputs(3). 2 - Print then replaces every occurence of Text_IO.Put_Line (I.e., even when building new strings from Ada strings for the C functions the speedup seems quite noticeable. There are no occurrences of unchecked conversions or other high speed techniques in the change (yet?).) Might a change like this be acceptable? (Obviously, fgets could similarly be used when reading input in other programs.) *** fasta.ada old --- fasta.ada new *************** *** 23 **** ! with Ada.Text_IO; use Ada.Text_IO; --- 23,25 ---- ! with Interfaces.C_Streams; use Interfaces.C_Streams; ! with Interfaces.C; use Interfaces.C; ! with Ada.IO_Exceptions; *************** *** 74 **** --- 77,84 ---- + procedure Print (Item : String) is + Data : char_array renames To_C (Item & ASCII.LF); + begin + if fputs (Data'Address, stdout) < 0 then + raise Ada.IO_Exceptions.Device_Error; + end if; + end Print; + *************** *** 82 **** ! Put_Line (">" & Id & ' ' & Desc); --- 92 ---- ! Print (">" & Id & ' ' & Desc); *************** *** 91 **** ! Put_Line (Pick (1 .. M)); --- 101 ---- ! Print (Pick (1 .. M)); *************** *** 101 **** ! Put_Line (">" & Id & ' ' & Desc); --- 111 ---- ! Print (">" & Id & ' ' & Desc); *************** *** 104 **** ! Put_Line (S_App (K .. K + Integer'Min(Todo, Line_Length) - 1)); --- 114 ---- ! Print (S_App (K .. K + Integer'Min(Todo, Line_Length) - 1));