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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,56525db28240414a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.224.177.12 with SMTP id bg12mr1448204qab.0.1343315804325; Thu, 26 Jul 2012 08:16:44 -0700 (PDT) Received: by 10.66.76.130 with SMTP id k2mr1803972paw.16.1343315714955; Thu, 26 Jul 2012 08:15:14 -0700 (PDT) Path: a15ni113198934qag.0!nntp.google.com!q21no4654415qas.0!news-out.google.com!p10ni61181651pbh.1!nntp.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!novia!news-peer1!btnet!zen.net.uk!hamilton.zen.co.uk!xlned.com!feeder1.xlned.com!border2.nntp.ams.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.straub-nv.de!news.antakira.com!news.glorb.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: robin.vowels@gmail.com Newsgroups: comp.lang.ada Subject: Re: Efficient Sequential Access to Arrays Date: Sun, 22 Jul 2012 03:09:44 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <01983f1c-f842-4b1f-a180-bcef531dad4c@googlegroups.com> NNTP-Posting-Host: 123.2.70.40 Mime-Version: 1.0 X-Trace: posting.google.com 1342951891 15162 127.0.0.1 (22 Jul 2012 10:11:31 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 22 Jul 2012 10:11:31 +0000 (UTC) In-Reply-To: <01983f1c-f842-4b1f-a180-bcef531dad4c@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=123.2.70.40; posting-account=S_MdrwoAAAD7T2pxG2e393dk6y0tc0Le User-Agent: G2/1.0 X-Original-Bytes: 2133 X-Received-Bytes: 2388 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-07-22T03:09:44-07:00 List-Id: On Monday, 16 July 2012 04:40:08 UTC+10, Keean Schupke wrote: > However in order to achieve this performance I needed to rework the array= s as the use of Indexes was too slow. An example of this is lets say we are= accessing element 5 from array A "A(5)" this requires a multipli= cation to access (base_address + index * record_size). To access the neighb= our A(6) also requires a multiplication. Accessing the array sequentially r= equires a multiplication per step. Have you tried turning on high optimisation? If you are accessing elements sequentially, the optimiser will probably not do multiplications, but instead access successive elements by means of additions. Other factors may be relevant: 1. For example, if the size of a record is small-ish, the compiler may use shifts and/or adds/subtracts instead of multiplications. 2. The hardware multiplier may be one of the fast kind, in which case the time is negligible.