home *** CD-ROM | disk | FTP | other *** search
- program mathtest;
- {
- This program performs timing tests on various floating
- point arithmetic operations.
-
-
- Source: "8087 Support: That Much Faster?", TUG Lines Volume I Issue 4
- Author: Richard Brush
- Application: IBM PC and true compatibles
- }
-
- {$R+}
-
- label done;
- var
- x,y,z: array[0..255] of real;
- i,j,jmax,n:integer;
-
- {$I B:TIMEPACK.PAS}
-
- {
- TimePack - a collection of procedures related to real time clock.
- The following procedures are included :
-
- procedure getime (var hrs,min,sec,csec:integer);
- procedure Telapsed (hrs1,min1,sec1,csec1,hrs2,min2,sec2,csec2:integer;
- var Timdif:real);
- procedure Twait (time:real);
- }
-
-
- begin {mathtest}
- for i:= 0 to 255 do
- begin
- x[i]:=random;
- y[i]:=random;
- end {for};
- while true do
- begin
- repeat
- ClrScr;
- writeln ('type in number to select operation, according to menu:');
- writeln (' 0: stop');
- writeln (' 1: null loop');
- writeln (' 2: add');
- writeln (' 3: subtract');
- writeln (' 4: multiply');
- writeln (' 5: divide');
- writeln (' 6: sqrt');
- writeln (' 7: sin');
- writeln (' 8: cos');
- writeln (' 9: exp');
- writeln (' 10: Logn');
- writeln (' 11: Arctan');
- writeln (' 12: compare');
- writeln (' 13: zero test');
- readln (n);
- until n in [0..13];
- if n=0 then goto done;
- repeat
- writeln ('type in number of iterations (1..32767)');
- readln (jmax);
- until (jmax >= 0) and (jmax <= maxint);
- getime (hrs1,min1,sec1,csec1);
- case n of
- 1: for j:=1 to jmax do
- begin
- i:= Lo(j);
- x[i]:= x[i]; {null operation}
- end;
- 2: for j:=1 to jmax do
- begin
- i:= Lo(j);
- z[i]:= x[i] + y[i];
- end;
- 3: for j:=1 to jmax do
- begin
- i:= Lo(j);
- z[i]:= x[i] - y[i];
- end;
- 4: for j:=1 to jmax do
- begin
- i:= Lo(j);
- z[i]:= x[i] * y[i];
- end;
- 5: for j:=1 to jmax do
- begin
- i:= Lo(j);
- z[i]:= x[i] / y[i];
- end;
- 6: for j:=1 to jmax do
- begin
- i:= Lo(j);
- z[i]:= sqrt ( x[i] );
- end;
- 7: for j:=1 to jmax do
- begin
- i:= Lo(j);
- z[i]:= sin ( x[i] );
- end;
- 8: for j:=1 to jmax do
- begin
- i:= Lo(j);
- z[i]:= cos ( x[i] );
- end;
- 9: for j:=1 to jmax do
- begin
- i:= Lo(j);
- z[i]:= exp ( x[i] );
- end;
- 10: for j:=1 to jmax do
- begin
- i:= Lo(j);
- z[i]:= Ln ( x[i] );
- end;
- 11: for j:=1 to jmax do
- begin
- i:= Lo(j);
- z[i]:= Arctan ( x[i] );
- end;
- 12: for j:=1 to jmax do
- begin
- i:= Lo(j);
- if x[i] = y[i] then
- begin
- end;
- end;
- 13: for j:=1 to jmax do
- begin
- i:= Lo(j);
- if x[i] = 0.0 then
- begin
- end;
- end;
- end {case};
- getime (hrs2,min2,sec2,csec2);
- Telapsed (hrs1,min1,sec1,csec1,hrs2,min2,sec2,csec2,Timdif);
- { Beep speaker. }
- Sound (500);
- Delay(200);
- NoSound;
- writeln ('hit any key to continue');
- repeat
- until KeyPressed;
- end {while};
- done:
- end {mathtest}.
-