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: 103376,64fc02e079586f1b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news2.google.com!proxad.net!newsfeed.stueberl.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: [Shootout] Spellcheck.adb Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1114464642.518876.137610@f14g2000cwb.googlegroups.com> Date: Tue, 26 Apr 2005 22:36:41 +0200 Message-ID: <4nm49tqq12fy.ucmt7m1938ld.dlg@40tude.net> NNTP-Posting-Date: 26 Apr 2005 22:36:27 MEST NNTP-Posting-Host: 688a8c11.newsread2.arcor-online.net X-Trace: DXC=0`7JQBjLT7c:35lZDPnnTlQ5U85hF6f;djW\KbG]kaMh:cmYYm_h3\c13:QQAVKlQmWRXZ37ga[7jncfD5BXcIX`9\djGgbLQ0e X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:10735 Date: 2005-04-26T22:36:27+02:00 List-Id: On 25 Apr 2005 14:30:42 -0700, albert.bachmann@gmx.de wrote: > on http://shootout.alioth.debian.org/ I discovered that the Ada entry > for the "spellcheck" benchmark produces an error according to the > information on that website. The specification for this benchmark can > be found here: > http://shootout.alioth.debian.org/benchmark.php?test=spellcheck&lang=all&sort=fullcpu > > Since I am new to Ada I decided that it might be a good idea to > implement a solution and see how it performs. Finally I came up with a > naive program that performs not very well in comparison to other > language implementations. I produced a naive implementation in C++ as > well which solves the problem in less than half the time. The entry for > C++ at the Shootout takes half the time of my naive solution. > > Now what I'd like to ask you is how I can speed up my Ada solution? As > I said I'm a novice and certainly there is a huge optimization > potential here. Here is the output of 'time': -------------- spell_check.adb ----------------- with Ada.Text_IO; use Ada.Text_IO; with Dictionary_Tables; use Dictionary_Tables; procedure Spell_Check is File : File_type; Line : String (1..130); Last : Natural; Dictionary : Table; begin Open (File, In_File, "spellcheck-dict.txt"); begin -- Reading dictionary loop Get_Line (File, Line, Last); Add (Dictionary, Line (Line'First..Last), true); end loop; exception when End_Error => null; end; Close (File); begin -- Reading test file loop Get_Line (Line, Last); begin if Find (Dictionary, Line (Line'First..Last)) then null; end if; exception when End_Error => Put_Line (Line (Line'First..Last)); end; end loop; exception when End_Error => null; end; end Spell_Check; ----------- dictionary_tables.adb ---------------------- with Tables; package Dictionary_Tables is new Tables (Boolean); The above is approximately five times faster on my computer under FC3. Probably, because it does not use hash tables? [ The package tables is here: http://www.dmitry-kazakov.de/ada/tables.htm ] -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de