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=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,13280cdb905844e4 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!d37g2000yqa.googlegroups.com!not-for-mail From: sjw Newsgroups: comp.lang.ada Subject: Re: Is there an Ada compiler whose Ada.Numerics.Generic_Elementary_Functions.Log(Base=>10, X=>variable) is efficient? Date: Mon, 15 Feb 2010 12:00:52 -0800 (PST) Organization: http://groups.google.com Message-ID: <993d3a57-ba45-4b5a-b61e-e6c2c8ad4283@d37g2000yqa.googlegroups.com> References: NNTP-Posting-Host: 82.30.110.254 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1266264052 20019 127.0.0.1 (15 Feb 2010 20:00:52 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 15 Feb 2010 20:00:52 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d37g2000yqa.googlegroups.com; posting-host=82.30.110.254; posting-account=_RXWmAoAAADQS3ojtLFDmTNJCT0N2R4U User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; en-us) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:9252 Date: 2010-02-15T12:00:52-08:00 List-Id: On Feb 15, 6:26=A0pm, "(see below)" wrote: > On 15/02/2010 10:58, in article > alpine.LNX.2.00.1002151055530.17...@Bluewhite64.example.net, "Colin Paul > > Gloster" wrote: > > Of the two programs shown, the fastest C++ implementation on one test > > platform took less than one millisecond and the fastest Ada > > implementation took one minute and 31 seconds and 874 milliseconds on > > the same platform. Both g++ and gnatmake were from the same > > installation of GCC 4.1.2 20080704 (Red Hat 4.1.2-44). > > Is that 1 millisecond for 1e6 calls? This implies 1ns per call in C++. > I find it incredible that a log function could be so fast. > I think the loop body must be evaluated at compile-time in C++. I think it's a mixture of your point & Jonathan's; the loop body, with the 500 calls to log10(), is executed once, then the compiler smartly realizes that each iteration produces the same increment.