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!r24g2000yqd.googlegroups.com!not-for-mail From: jonathan 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 10:51:41 -0800 (PST) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 143.117.23.232 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1266259901 13223 127.0.0.1 (15 Feb 2010 18:51:41 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 15 Feb 2010 18:51:41 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r24g2000yqd.googlegroups.com; posting-host=143.117.23.232; posting-account=Jzt5lQoAAAB4PhTgRLOPGuTLd_K1LY-C User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.16) Gecko/2009121609 Iceweasel/3.0.6 (Debian-3.0.6-3),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:9245 Date: 2010-02-15T10:51:41-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++. > > On my system your Ada code gives: > > 6.34086408536266E+08 > > real =A0 =A00m33.918s > user =A0 =A00m33.864s > sys =A0 =A0 0m0.025s > >... if I replace the C++ loop body by: > > =A0 =A0 =A0 for(int j=3D1; j<=3D500; ++j) > =A0 =A0 =A0 =A0 =A0answer +=3D std::log10(j*0.100000000000000000000); > It now gives: > > 6.34086e+08 > real =A0 =A00m18.112s > user =A0 =A00m18.082s > sys =A0 =A00m0.015s > > Bill Findlay > chez blueyonder.co.uk On my computer, Log_base_10_of_e * Log (y) is twice as fast as Log (y, Base =3D> 10.0). Jonathan