|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: B T
Length: 4268 (0x10ac)
Types: TextFile
Names: »B«
└─⟦180fe333a⟧ Bits:30000405 8mm tape, Rational 1000, SW CATALOG, 10_20_0
└─⟦180fe333a⟧ Bits:30000537 8mm tape, Rational 1000, SW Catalog 10_20_0
└─⟦5cb1d1d7f⟧ »DATA«
└─⟦3b1ee7bd8⟧
└─⟦this⟧
--
-- Version: @(#)akerman.ada 2.3 Date: 9/21/84
--
-- Author: Brian A. Wichmann
-- National Physical Laboratory
-- Teddington, Middlesex TW11 OLW, UK
--
-- Modified by LA AdaTEC to conform to ANSI Standard Ada & to test
-- for significance of elapsed time.
--
-- [Extracts from: "Latest resuts from the procedure calling test,
-- Ackermann's function", B. A. Wichamann, NPL Report DITC 3/82,
-- ISSN 0143-7348]
--
-- Ackermann's function has been used to measure the procedure calling
-- overhead in languages which support recursion [Algol-like languages,
-- Assembly Languages, & Basic]
--
-- Ackermann's function is a small recursive function .... Although of
-- no particular interest in itself, the function does perform other
-- operations common to much systems programming (testing for zero,
-- incrementing and decrementing integers). The function has two
-- parameters M and N, the test being for (3, N) with N in the range
-- 1 to 6.
--
-- [End of Extract]
--
-- The object code size of the Ackermann function should be reported in
-- 8-bit bytes, as well as, the Average Number of Instructions Executed
-- per Call of the Ackermann function. Also, if the stack space is
-- exceeded, report the parameter values used as input to the initial
-- invocation of the Ackermann function.
--
-- The Average Number of Instructions Executed Per Call should preferably
-- be determined by examining the object code and calculating the number
-- of instructions executed for a significant number of calls of the
-- Ackermann function (see below). If that is not possible,
-- please make an estimate based the average execution time per machine
-- instruction for the target machine and the average time per call for
-- a significant number of calls. Clearly indicate whether the Average
-- Number of Instructions Executed Per Call is an estimate or not.
--
-- Note: In order for the measurement to be meaningful, it must be the
-- only program executing while the test is run. The number of calls is
-- significant if the elapsed time for the initial invocation of the
-- Ackermann's function is at least 100 times Duration'Small & at least
-- 100 times System.Tick).
--
with Text_Io;
use Text_Io;
with Calendar;
use Calendar;
with System;
use System;
procedure Time_Ackermann is
type Real_Time is digits Max_Digits;
Start_Time : Time;
Elapsed_Time : Duration;
Average_Time : Real_Time;
package Duration_Io is new Fixed_Io (Duration);
use Duration_Io;
package Real_Time_Io is new Float_Io (Real_Time);
use Real_Time_Io;
package Int_Io is new Integer_Io (Integer);
use Int_Io;
I, J, K, K1, Calls : Integer;
function Ackermann (M, N : Natural) return Natural is
begin
if M = 0 then
return N + 1;
elsif N = 0 then
return Ackermann (M - 1, 1);
else
return Ackermann (M - 1, Ackermann (M, N - 1));
end if;
end Ackermann;
begin
K := 16;
K1 := 1;
I := 1;
while K1 < Integer'Last / 512 loop
Start_Time := Clock;
J := Ackermann (3, I);
Elapsed_Time := Clock - Start_Time;
if J /= K - 3 then
Put_Line (" *** Wrong Value ***");
end if;
Calls := (512 * K1 - 15 * K + 9 * I + 37) / 3;
Put ("Number of Calls = ");
Put (Calls, Width => 0);
New_Line;
Put ("Elapsed Time = ");
Put (Elapsed_Time, Fore => 0);
Put (" seconds -- precision is ");
if (Elapsed_Time < 100 * Duration'Small or
Elapsed_Time < 100 * System.Tick) then
Put_Line ("Insignificant");
else
Put_Line ("Significant");
end if;
Average_Time := Real_Time (Elapsed_Time / Calls);
Put ("Average Time per call = ");
Put (Average_Time, Fore => 0);
Put_Line (" seconds");
New_Line;
I := I + 1;
K1 := 4 * K1;
K := 2 * K;
end loop;
Put_Line (" End of Ackermann Test");
exception
when Storage_Error =>
New_Line;
Put ("Stack space exceeded for Ackermann ( 3, ");
Put (I);
Put_Line (")");
New_Line;
Put_Line (" End of Ackermann Test");
end Time_Ackermann;