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!feed.news.tiscali.de!news.belwue.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> <4nm49tqq12fy.ucmt7m1938ld.dlg@40tude.net> Date: Wed, 27 Apr 2005 10:40:09 +0200 Message-ID: <162n63ifx5jhn$.x4a2jtiveto0.dlg@40tude.net> NNTP-Posting-Date: 27 Apr 2005 10:40:09 MEST NNTP-Posting-Host: 8200a686.newsread2.arcor-online.net X-Trace: DXC=QXIEaZA@55K[T26?78JQ5U85hF6f;DjW\KbG]kaMH:cmYYm_h3\Cfn`O1iBMRjNWRXZ37ga[7Jn919Q4_`VjIB8=X\UUgbkD X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:10749 Date: 2005-04-27T10:40:09+02:00 List-Id: On Tue, 26 Apr 2005 23:50:12 +0200, David Sauvage wrote: > Dmitry A. Kazakov wrote: >> ... >> The above is approximately five times faster on my computer under FC3. >> Probably, because it does not use hash tables? > > GNAT.Spitbol.Table generic use hash tables (i wonder if it could be > called an hashed table maps method?), may be people would like to have a > look on it's hash function (see #1) > > The published shootout Ada spellcheck using GNAT.Spitbol.Table : > real 0m0.120s > user 0m0.083s > sys 0m0.007s > > (i run all the programs several times before each post ;-), so i get > fresh time average each post) > > I try using the Tables generic package implementation (see #2) instead > of GNAT.Spitbol.Table generic on the shootout Ada spellcheck > implementation, which gave me : > real 0m0.271s > user 0m0.197s > sys 0m0.014s Aha, now it is how it must be! (:-)) Hash table should be slower than sorted arrays on natural dictionaries. But because it is allocated in advance (40_000 items), that should give it an advantage over a dynamically allocated sorted array, when sizes of the dictionary and of the text are close: 1 x malloc + n x string compare >> n x (hash + integer compare), though string compare < hash + integer compare when n ~ 1 two times looks OK. [I can't stop wondering how badly wrong the benchmarks were designed] BTW, you can try to use streams in the second part of your code. That should bring another 10ms or so. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de