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.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7e15102eb14c0020 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.216.193.131 with SMTP id k3mr868908wen.4.1349078877226; Mon, 01 Oct 2012 01:07:57 -0700 (PDT) Path: q10ni47419980wif.0!nntp.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!217.188.199.168.MISMATCH!takemy.news.telefonica.de!telefonica.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Mon, 01 Oct 2012 10:07:33 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: highest bit, statically determined References: <50673111$0$9505$9b4e6d93@newsspool1.arcor-online.net> <38594cbf-b52d-4002-8db9-410f55126a09@googlegroups.com> In-Reply-To: <38594cbf-b52d-4002-8db9-410f55126a09@googlegroups.com> Message-ID: <50694f43$0$6577$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 01 Oct 2012 10:07:31 CEST NNTP-Posting-Host: 8892f5a3.newsspool3.arcor-online.net X-Trace: DXC=g^g30;]_28`^Y=RbYBPl4`McF=Q^Z^V3h4Fo<]lROoRa8kF_ljHilPCY\c7>ejVhA=7823L\`akY\]5eQ>3Mhm X-Complaints-To: usenet-abuse@arcor.de Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-10-01T10:07:31+02:00 List-Id: On 30.09.12 17:39, Anatoly Chernyshev wrote: > Ouch... > with ada.numerics.elementary_functions; > use ada.numerics.elementary_functions; > Highest_Bit_In_Octet:=natural(float'truncation(log(float(N),2.0))); > > I didn't check it for speed though. Pros that it doesn't depend on the size. I did. And this time I had the program actually call the randomizing Initialize I had written for the test data. .-/ Results have changed in favor of the recursive first_1_bit_a. The test is running on a laptop, so it likely says little about results on a microcontroller. x an array of 12_000 octets, 10_000 iterations for each test. First row : Count(f(x_{k}) = f(x_{k + 1})), second row : time in seconds 68580000 2.635991000 -- f is first_1_bit 68580000 2.036651000 -- f is first_1_bit_a 68580000 27.735934000 -- f is first_1_bit_log with inline expansion: 68580000 1.687923000 68580000 1.447859000 68580000 24.481472000 Slightly faster in both cases when translation suppresses checks, the integer versions more than the FPT version.