home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega CD-ROM 1
/
megacd_rom_1.zip
/
megacd_rom_1
/
MAGAZINE
/
INSIDE_T
/
ITPJUN90.ZIP
/
TEST.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1990-05-10
|
2KB
|
61 lines
PROGRAM Test;
{ TEST - Test the timer library. This Program
times how long it takes to obtain the current
time with the two methods described in the
article. }
USES Crt,Dos,Timer;
VAR
EmptyLoopTime : Real;
Q : Longint;
PROCEDURE PrintResults(A,B: Longint;S1,S2:String);
{PrintResults procedure displays accurate message
only if you run the test loop 1,000,000 times}
VAR
tInterval : Real;
BEGIN
WriteLn(tFormat(A,B),
' seconds FOR 1,000,000 invocations OF ',S1);
tInterval := tDiff(A,B) - EmptyLoopTime;
{Adjust display for midnight crossover
60*60*24 is the number of seconds in a day}
IF tInterval < 0 THEN
tInterval := tInterval + (60*60*24);
WriteLn('This equals ',tInterval:8:6,
' µs per ',S2);
WriteLn
END;
VAR
T1,T2,I,J : Longint;
Hour, Minute, Second, Sec100 : Word;
BEGIN
ClrScr;
T1 :=tStart;
FOR I:= 1 TO 1000000 DO;
T2 := tGet;
PrintResults(T1,T2,'*** Empty Loop ***',
'Loop.');
EmptyLoopTime := tDiff(T1,T2);
{How long does it take to call GetTime?}
T1 := tStart;
FOR I:= 1 TO 1000000 DO
Dos.GetTime(Hour, Minute, Second, Sec100);
T2 := tGet;
PrintResults(T1,T2,'*** Dos.GetTime() ***',
'call.');
T1 := tStart;
FOR I:= 1 TO 1000000 DO
Timer.GetTime(Hour,Minute,Second,Sec100);
T2 := tGet;
PrintResults(T1,T2,'*** Timer.GetTime() ***',
'call.');
T1 := tStart;
FOR I:= 1 TO 1000000 DO
Q := tGet;
T2 := tGet;
PrintResults(T1,T2,'*** tGet() ***','call.');
WriteLn('Tests Completed')
END.