with Report; with Ada.Real_Time; with Text_IO; procedure Sieve is use Report; use Ada.Real_Time; use Text_IO; package IO is new Integer_IO (Integer); use IO; Start_Time, Stop_Time : Time; -- Size : constant := 8190; k, Prime, Count : Natural; type ftype is array (0 .. Size) of Boolean; Flags : Ftype; begin Test ("sieve", "The Sieve benchmark"); Start_Time := Clock; for Iter in 1 .. 10 loop Count := 0; for i in 0 .. Size loop Flags (i) := True; end loop; for i in 0 .. Size loop if Flags (i) then Prime := i + i + 3; k := i + Prime; while k <= Size loop Flags (k) := False; k := k + Prime; end loop; Count := Count + 1; end if; end loop; end loop; Stop_Time := Clock; if Count /= 1899 then Failed ("Count has wrong value"); end if; Put ("Time taken = "); Put (Integer (1000.0 * To_Duration (Time_Span'(Stop_Time - Start_Time))), 0); Put (" mSec"); New_Line; Result; end Sieve;