home *** CD-ROM | disk | FTP | other *** search
- Program ExtTest;
-
- { Don't let the Random access test results fool you. At 200000 Longints,
- this is still a high load-factor ExtendedArray (22 lobes, 8 in Ram). Try
- it with 2000000 for comparison. }
-
- Uses ExtArray,Crt;
-
- Const
- NumEl = 200000;
-
- Var
- V : ExtendedArray;
- I,J : LongInt;
- E : LongInt;
- Base : Array[0..999] of LongInt;
- W : Word;
-
- Begin
- ClrScr;
- Randomize;
- V.Create;
- WriteLn ('MemAvail Before Initialization = ',MemAvail);
- V.AutoInit (NumEl,SizeOf(LongInt));
- WriteLn (SizeOf(V),' Bytes occupied by Object');
- WriteLn ('MemAvail after Initialization = ',MemAvail);
- Write ('Initializing...');
- For W := 0 to 999 do Base[W] := W;
- For I := NumEl-1 downto 0 do
- Begin
- E := I;
- V.Accept (E,I,SizeOf (LongInt))
- End;
- ClrScr;
- WriteLn ('Timing Tests for Random Access.');
-
- Write ('Press <Return> to begin test of 10000 (RANDOM) Accesses of Standard Array...');
- ReadLn;
- For I := 0 to 9999 do
- Begin
- W := Base[Random(1000)];
- GoToXY (10,13);
- Write ('Accessing Element # ',W);
- ClrEol
- End;
-
- ClrScr;
- Write ('Press <Return> to begin test of 10000 (RANDOM) Accesses of Extended Array...');
- ReadLn;
-
- For I := 0 to 9999 do
- Begin
- J := Longint (Round (Random * NumEl));
- GoToXY (10,13);
- Write ('Accessing Element # ',J);
- ClrEol;
- V.Retrieve (E,J,SizeOf (LongInt))
- End;
-
- Write ('Waiting...');
- ReadLn;
- WriteLn ('Destroying...');
- V.Destroy
- End.