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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.236.41.100 with SMTP id g64mr700170yhb.31.1380697289651; Wed, 02 Oct 2013 00:01:29 -0700 (PDT) X-Received: by 10.49.3.134 with SMTP id c6mr27412qec.0.1380697289634; Wed, 02 Oct 2013 00:01:29 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!q9no899737qas.0!news-out.google.com!9ni1076qaf.0!nntp.google.com!q9no899731qas.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 2 Oct 2013 00:01:29 -0700 (PDT) In-Reply-To: <8aca502c-bba8-4af5-9192-459c15fe048b@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=193.71.180.107; posting-account=uulyKwoAAAA86DO0ODu--rZtbje8Sytn NNTP-Posting-Host: 193.71.180.107 References: <8aca502c-bba8-4af5-9192-459c15fe048b@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3925301c-22af-4d37-8ab0-28ded42d5252@googlegroups.com> Subject: Re: Optimizing Ada From: Egil H H Injection-Date: Wed, 02 Oct 2013 07:01:29 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:17371 Date: 2013-10-02T00:01:29-07:00 List-Id: On Wednesday, October 2, 2013 4:58:40 AM UTC+2, kennet...@gmail.com wrote: > > The only real snags I've hit with Ada is trouble with finding documentation on the standard library. > The Standard Library is defined in Annex A of the reference manual, http://www.adaic.org/resources/add_content/standards/12rm/html/RM-A.html Specifically, see section A.18.4 for a description of Maps: http://www.adaic.org/resources/add_content/standards/12rm/html/RM-A-18-4.html > > Ada Code : http://pastebin.com/vDbdXCYD (a quotation mark messed up highlighting near bottom) > You could try to preallocate space in the Word_Map by calling Word_Map.Reserve_Capacity(some_fairly_large_number); Also, you're calling Update_Element even for new words. Depending on your dataset, that could potentially be a lot of unneccessary callbacks. Try this: Word_Map.Insert(Key => Word, New_Item => 1, -- <---- Position => Location, Inserted => Added); if not Added then Word_Map.Update_Element(Position => Location, Process => Increment_By_One'Access); end if; Rust probably have a faster hash function (seems they use SipHash 2-4). Try to implement the same algorithm in Ada, see if that makes a difference.