From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Not good for Ada endorsement Date: Thu, 8 Jul 2021 10:42:40 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <5a1cegtfm5ibqej3ldebpc4g99ujniqt9u@4ax.com> NNTP-Posting-Host: 5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:62351 List-Id: On 2021-07-08 10:20, Jeffrey R. Carter wrote: > On 7/8/21 5:46 AM, Richard Iswara wrote: >> Indirectly it is a comparison of implementation and tools >> benchmarking. Looking at the gpr file, there is no compile switch >> used, not even an "-o2" switch. > > Compiling with -gnatp -O3 would undoubtedly speed it up (suppressing > checks is justified since execution with checks active shows that no > checks fail). > > Looking casually at the code, the map could be replaced by a constant, > as Sieve_Size is hard coded to 1,000,000, and the filling of the map is > included in the timing. The calculation of the square root of 1,000,000 > could be replaced by a constant. The array of Boolean could be > constrained to 3 .. Sieve_Size. The function that simply returns (others > => True) could be replaced by the aggregate, though optimization will > probably do that. Long_Long_Integer could be replaced by a type with > range 0 .. 2 ** 31 - 1, though I don't know if that would have any > effect. The first inner loop in the sieve algorithm could be eliminated, > in which case the initialization of Num could also be removed. Exactly, this is what is wrong with such contests. The solution is non-scalable giving advantage to low-level languages like C. Scalability and readability has the price that hobby-sized instances work poorly. P.S. I would also suggest ensuring the Boolean array not packed. If not with compiler switches and pragmas then by declaring a custom Boolean 1,2,4,8 bytes long depending on the target architecture. It is not a fair play, guys! -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de