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.6 required=5.0 tests=BAYES_00,DATE_IN_PAST_24_48, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,56525db28240414a,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.224.39.72 with SMTP id f8mr3590718qae.7.1342524261342; Tue, 17 Jul 2012 04:24:21 -0700 (PDT) Received: by 10.68.223.40 with SMTP id qr8mr2193806pbc.0.1342524261103; Tue, 17 Jul 2012 04:24:21 -0700 (PDT) Path: a15ni11984qag.0!nntp.google.com!x2no6951138qaj.0!news-out.google.com!p10ni155326254pbh.1!nntp.google.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newspump.sol.net!news-out.octanews.net!mauve.octanews.net!feed.news.qwest.net!mpls-nntp-01.inet.qwest.net!83.149.209.203.MISMATCH!news.mi.ras.ru!goblin-spool!goblin1!goblin.stu.neva.ru!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Keean Schupke Newsgroups: comp.lang.ada Subject: Efficient Sequential Access to Arrays Date: Sun, 15 Jul 2012 11:40:08 -0700 (PDT) Organization: http://groups.google.com Message-ID: <01983f1c-f842-4b1f-a180-bcef531dad4c@googlegroups.com> NNTP-Posting-Host: 82.44.19.199 Mime-Version: 1.0 X-Trace: posting.google.com 1342377608 24062 127.0.0.1 (15 Jul 2012 18:40:08 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 15 Jul 2012 18:40:08 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=82.44.19.199; posting-account=T5Z2vAoAAAB8ExE3yV3f56dVATtEMNcM User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-07-15T11:40:08-07:00 List-Id: The Monte-Carlo simulator I am working on is now performing better in Ada t= han in C++ using profile-guided compilation (57k simulations per second for= Ada 'vs' 56k simulations per second for C++). However in order to achieve this performance I needed to rework the arrays = as the use of Indexes was too slow. An example of this is lets say we are a= ccessing element 5 from array A "A(5)" this requires a multiplication to ac= cess (base_address + index * record_size). To access the neighbour A(6) als= o requires a multiplication. Accessing the array sequentially requires a mu= ltiplication per step.=20 Contrast this with C++ where we can return a pointer to the array element, = and we just need to add the record_size to step to the next element. So assuming we need this level of performance, what would be the best (and = most idiomatic Ada) way to package this type of usage pattern as an abstrac= t datatype? Cheers, Keean.