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.
--
Jeff Carter
"My legs are gray, my ears are gnarled, my eyes are old and bent."
Monty Python's Life of Brian
81