-- FloatTimeTest.mesa to measure speed of number stuff
-- Copywrite Xerox Corporation 1980
-- Originally by J. Maleson
-- Modified by L. Stewart May 27, 1980 1:00 PM
-- added assignment, comparision
DIRECTORY
IODefs: FROM "IODefs",
Mopcodes: FROM "Mopcodes",
SDDefs: FROM "SDDefs",
RealDefs: FROM "RealDefs",
WF: FROM "WF";
FloatTimeTest: PROGRAM IMPORTS IODefs, RealDefs, WF =
BEGIN OPEN IODefs, RealDefs, WF;
sNullProc: CARDINAL = 140B; -- (hopefully) empty SD slot
r,s,t: REAL;
q: LONG INTEGER;
RTC: POINTER TO CARDINAL = LOOPHOLE[430B];
Disp: POINTER TO CARDINAL = LOOPHOLE[420B];
odcb, card: CARDINAL;
int: INTEGER;
i: CARDINAL;
numTests: CARDINAL;
loopTime,assgnTime,nullSDTime,addTime: CARDINAL;
subTime,mulTime,divTime,compTime,fixTime,floatTime: CARDINAL;
startTime,endTime: CARDINAL;
equal: BOOLEAN;
NullProc: PROCEDURE[a,b: REAL] RETURNS [REAL] =
BEGIN
RETURN[a];
END;
zNullProc: PROCEDURE[a,b: REAL] RETURNS [REAL] =
MACHINE CODE BEGIN
Mopcodes.zKFCB, sNullProc;
END;
SDDefs.SD[sNullProc] ← NullProc;
DO
WF0["Number of tests? (decimal): "];
numTests ← ReadDecimal[];
WF0["*nArguments (float) ? x: "];
r ← ReadFloat[];
WF0[" y: "];
s ← ReadFloat[];
WF0["*n"];
odcb ← Disp↑;
Disp↑ ← 0;
startTime ← RTC↑;
FOR i IN [0..numTests) DO ENDLOOP;
endTime ← RTC↑;
Disp↑ ← odcb;
loopTime ← endTime-startTime;
WF1["empty loop: %d*n",(loopTime*39)];
odcb ← Disp↑;
Disp↑ ← 0;
startTime ← RTC↑;
FOR i IN [0..numTests) DO t ← r; ENDLOOP;
endTime ← RTC↑;
Disp↑ ← odcb;
assgnTime ← endTime-startTime;
WF1["assignment: %d*n",(assgnTime*39)];
odcb ← Disp↑;
Disp↑ ← 0;
startTime ← RTC↑;
FOR i IN [0..numTests) DO t ← zNullProc[r,s]; ENDLOOP;
endTime ← RTC↑;
Disp↑ ← odcb;
nullSDTime ← endTime-startTime;
WF1["null SD: %d*n",(nullSDTime*39)];
odcb ← Disp↑;
Disp↑ ← 0;
startTime ← RTC↑;
FOR i IN [0..numTests) DO t ← r + s; ENDLOOP;
endTime ← RTC↑;
Disp↑ ← odcb;
addTime ← endTime - startTime;
WF1["add: %d*n",(addTime*39)];
odcb ← Disp↑;
Disp↑ ← 0;
startTime ← RTC↑;
FOR i IN [0..numTests) DO t ← r - s; ENDLOOP;
endTime ← RTC↑;
Disp↑ ← odcb;
subTime ← endTime - startTime;
WF1["sub: %d*n",(subTime*39)];
odcb ← Disp↑;
Disp↑ ← 0;
startTime ← RTC↑;
FOR i IN [0..numTests) DO t ← r * s; ENDLOOP;
endTime ← RTC↑;
Disp↑ ← odcb;
mulTime ← endTime - startTime;
WF1["mul: %d*n",(mulTime*39)];
odcb ← Disp↑;
Disp↑ ← 0;
startTime ← RTC↑;
FOR i IN [0..numTests) DO t ← r / s; ENDLOOP;
endTime ← RTC↑;
Disp↑ ← odcb;
divTime ← endTime - startTime;
WF1["div: %d*n",(divTime*39)];
odcb ← Disp↑;
Disp↑ ← 0;
startTime ← RTC↑;
FOR i IN [0..numTests) DO equal ← r=s; ENDLOOP;
endTime ← RTC↑;
Disp↑ ← odcb;
compTime ← endTime - startTime;
WF1["comp: %d*n",(compTime*39)];
odcb ← Disp↑;
Disp↑ ← 0;
startTime ← RTC↑;
FOR i IN [0..numTests) DO q ← Fix[r]; ENDLOOP;
endTime ← RTC↑;
Disp↑ ← odcb;
fixTime ← endTime - startTime;
WF1["fix: %d*n",(fixTime*39)];
odcb ← Disp↑;
Disp↑ ← 0;
startTime ← RTC↑;
FOR i IN [0..numTests) DO int ← FixI[r]; ENDLOOP;
endTime ← RTC↑;
Disp↑ ← odcb;
fixTime ← endTime - startTime;
WF1["fixI: %d*n",(fixTime*39)];
odcb ← Disp↑;
Disp↑ ← 0;
startTime ← RTC↑;
FOR i IN [0..numTests) DO card ← FixC[r]; ENDLOOP;
endTime ← RTC↑;
Disp↑ ← odcb;
fixTime ← endTime - startTime;
WF1["fixC: %d*n",(fixTime*39)];
q ← Fix[r];
odcb ← Disp↑;
Disp↑ ← 0;
startTime ← RTC↑;
FOR i IN [0..numTests) DO t ← q; ENDLOOP;
endTime ← RTC↑;
Disp↑ ← odcb;
floatTime ← endTime - startTime;
WF1["float: %d*n",(floatTime*39)];
[]←ReadChar[];
ENDLOOP;
END.