/mobile Handheld Friendly website

 performance measurements

Each table row shows performance measurements for this Ada 2005 GNAT program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
500,0002.922.946,864560  1% 0% 1% 99%
5,000,00029.1529.196,860560  1% 1% 1% 100%
50,000,000297.74297.926,860560  0% 0% 0% 100%

Read the ↓ make, command line, and program output logs to see how this program was run.

Read thread-ring benchmark to see what this program should do.

 notes

GNATMAKE 4.6

gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu8)

 thread-ring Ada 2005 GNAT #2 program source code

-- The Computer Language Benchmarks Game
-- http://benchmarksgame.alioth.debian.org/
-- Contributed by Jacob Sparre Andersen (with help from Alex Mason)
--
-- Compile with:
--    gnatmake -gnat05 -gnatE -gnato -gnatv -gnati1 -gnatf -m -O3 -funroll-loops -funwind-tables -gnatn -fomit-frame-pointer -march=native thread_ring

with Ada.Text_IO;
with Ada.Command_line;

procedure ThreadRing is
   Ring_Size : constant := 503;
   type Ring_Index is mod Ring_Size;

   package Ring_Text_IO is new Ada.Text_IO.Modular_IO (Ring_Index);

   protected type Store is
      entry Put  (Item : in     Integer);
      entry Take (Item :    out Integer);
   private
      Value : Integer;
      Full  : Boolean := False;
   end Store;

   protected body Store is
      entry Put (Item : in     Integer) when not Full is
      begin
         Value := Item;
         Full := True;
      end Put;

      entry Take (Item :    out Integer) when Full is
      begin
         Item := Value;
         Full := False;
      end Take;
   end Store;

   type Store_Ring is array (Ring_Index) of Store;
   Stores : Store_Ring;

   task type Node is
      entry Initialize (Identifier  : in     Ring_Index);
   end Node;

   task body Node is
      ID    : Ring_Index;
      Token : Integer;
   begin
      accept Initialize (Identifier  : in     Ring_Index) do
         ID := Identifier;
      end Initialize;

      loop
         Stores (ID).Take (Token);

         if Token = 0 then
            Ring_Text_IO.Put (ID, Width => 0);
            Ada.Text_IO.New_Line;
         end if;

         Stores (ID + 1).Put (Token - 1);

         exit when Token < 0;
      end loop;
   end Node;

   type Node_Ring is array (Ring_Index) of Node;
   Nodes : Node_Ring;
begin
   for ID in Nodes'Range loop
      Nodes (ID).Initialize (Identifier => ID);
   end loop;

   Stores (1).Put (Integer'Value (Ada.Command_Line.Argument (1)));
end ThreadRing;

 make, command-line, and program output logs

Mon, 21 Oct 2013 00:57:11 GMT

MAKE:
/usr/bin/gnatchop -r -w threadring.gnat-2.gnat
splitting threadring.gnat-2.gnat into:
   threadring.adb
/usr/bin/gnatmake -O3 -fomit-frame-pointer -march=native -msse3 -mfpmath=sse -gnatNp -f threadring.adb -o threadring.gnat-2.gnat_run 
gcc-4.6 -c -O3 -fomit-frame-pointer -march=native -msse3 -mfpmath=sse -gnatNp threadring.adb
gnatbind -x threadring.ali
gnatlink threadring.ali -O3 -fomit-frame-pointer -march=native -msse3 -mfpmath=sse -o threadring.gnat-2.gnat_run
0.48s to complete and log all make actions

COMMAND LINE:
./threadring.gnat-2.gnat_run 50000000

PROGRAM OUTPUT:
292

Revised BSD license

  Home   Conclusions   License   Play