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,00012.316.7218,036602  37% 53% 53% 36%
5,000,000139.8875.0120,700602  47% 46% 44% 46%
50,000,0001,424.28762.9219,820602  46% 46% 45% 45%

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

GNAT 4.6

gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)

 thread-ring Ada 2005 GNAT program source code

-- The Computer Language Benchmarks Game

-- http://benchmarksgame.alioth.debian.org/

-- contributed by Jim Rogers


with Ada.Text_Io; use Ada.Text_Io;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure ThreadRing is
   
   protected Flag is
      procedure Set(Num : Positive);
      entry Wait(Last : out Positive);
   private
      Done : Boolean := False;
      Id : Positive;
   end Flag;
   protected body Flag is
      procedure Set(Num : Positive) is
      begin
         Done := True;
         Id := Num;
      end Set;
      entry Wait(Last : out Positive) when Done is
      begin
         Last := Id;
      end Wait;
   end Flag;

   type Node;
   type Node_Access is access Node;
   
   Ring : array(1..503) of Node_Access;
   
   task type Node(Id : Positive) is
      entry Start(Next : Node_Access);
      entry Put(Item : in Natural);
      entry Stop;
   end Node;
   
   task body Node is
      Val : Natural;
      Next_Node : Node_Access;
   begin
      accept Start(Next : Node_Access) do
         Next_Node := Next;
      end Start;
      
      loop
         select
            accept Put(Item : in Natural) do
               Val := Item;
            end Put;
         or
            accept Stop;
            exit;
         end select;
         if Val > 0 then
            Val := Val - 1;
            Next_Node.Put(Val);
         else
            Flag.Set(Id);
         end if;
      end loop;
   end Node;
   
   Num_Passes : Natural;
   Last_Node : Positive;
begin
   Num_Passes := Natural'Value(Argument(1));
   for I in Ring'range loop
      Ring(I) := new Node(I);
   end loop;
   Ring(Ring'Last).Start(Ring(1));
   for I in Ring'First..Ring'Last - 1 loop
      Ring(I).Start(Ring(I + 1));
   end loop;
   Ring(1).Put(Num_Passes);
   Flag.Wait(Last_Node);
   Put(Item => Last_Node, Width => 1);
   New_Line;
   for I in Ring'range loop
      Ring(I).Stop;
   end loop;
   
end ThreadRing;

 make, command-line, and program output logs

Sun, 27 Apr 2014 02:40:09 GMT

MAKE:
/usr/bin/gnatchop -r -w threadring.gnat
splitting threadring.gnat into:
   threadring.adb
/usr/bin/gnatmake -O3 -fomit-frame-pointer -march=native -msse3 -mfpmath=sse -gnatNp -f threadring.adb -o threadring.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_run
0.49s to complete and log all make actions

COMMAND LINE:
./threadring.gnat_run 50000000

PROGRAM OUTPUT:
292

Revised BSD license

  Home   Conclusions   License   Play