2
0
Эх сурвалжийг харах

* reduce counters for sparc

peter 21 жил өмнө
parent
commit
056201180f
1 өөрчлөгдсөн 57 нэмэгдсэн , 43 устгасан
  1. 57 43
      tests/test/theap.pp

+ 57 - 43
tests/test/theap.pp

@@ -5,6 +5,14 @@
 }
 PROGRAM TestHeap;
 
+
+const
+{$ifdef cpusparc}
+  Blocks = 1000;
+{$else}
+  Blocks = 10000;
+{$endif}  
+  
 Procedure InitMSTimer;
 begin
 end;
@@ -18,12 +26,18 @@ begin
 end;
 
 
-VAR Dummy,Start, LoopTime,LoopTime2: LONGINT;
+procedure ShowHeap;
+begin
+   WriteLn ('MaxAvail: ', MaxAvail, '   MemAvail: ', MemAvail,'   Heapsize: ',Heapsize);
+end;
+
+
+VAR Start, LoopTime,LoopTime2: LONGINT;
     Delta, TotalTime: LONGINT;
     L,Choice,K,T: WORD;
-    BlkPtr:  ARRAY [1..10000] OF POINTER;
-    BlkSize: ARRAY [1..10000] OF WORD;
-    Permutation: ARRAY [1..10000] OF WORD;
+    BlkPtr:  ARRAY [1..Blocks] OF POINTER;
+    BlkSize: ARRAY [1..Blocks] OF WORD;
+    Permutation: ARRAY [1..Blocks] OF WORD;
 
 BEGIN
   INitMSTimer;
@@ -31,57 +45,57 @@ BEGIN
    WriteLn;
    TotalTime := 0;
    RandSeed := 997;
-   WriteLn ('MaxAvail: ', MaxAvail, '   MemAvail: ', MemAvail);
+   ShowHeap;
    Start :=MSTimer;
-   FOR L := 1 TO 10000 DO BEGIN
+   FOR L := 1 TO Blocks DO BEGIN
    END;
    LoopTime := MSTimer-Start;
-   FOR L := 1 TO 10000 DO BEGIN
+   FOR L := 1 TO Blocks DO BEGIN
       BlkSize [L] := Random (512) + 1;
    END;
-   Write ('Allocating 10000 blocks at the end of the heap: ');
+   Write ('Allocating ',Blocks,' blocks at the end of the heap: ');
    Start := MSTImer;
-   FOR L := 1 TO 10000 DO BEGIN
+   FOR L := 1 TO Blocks DO BEGIN
       GetMem (BlkPtr [L], BlkSize [L]);
    END;
    Delta := MSTimer-Start-LoopTime;
    Inc (TotalTime, Delta);
    WriteLn (Delta:5, ' ms');
-   WriteLn ('MaxAvail: ', MaxAvail, '   MemAvail: ', MemAvail);
-   Write ('Deallocating same 10000 blocks in reverse order:');
+   ShowHeap;
+   Write ('Deallocating same ',Blocks,' blocks in reverse order:');
    Start := MSTimer;
-   FOR L := 1 TO 10000 DO BEGIN
+   FOR L := 1 TO Blocks DO BEGIN
       FreeMem (BlkPtr [L], BlkSize [L]);
    END;
    Delta := MSTimer-Start-LoopTime;
    Inc (TotalTime, Delta);
    WriteLn (Delta:5, ' ms');
-   WriteLn ('MaxAvail: ', MaxAvail, '   MemAvail: ', MemAvail);
-   Write ('Allocating 10000 blocks at the end of the heap: ');
+   ShowHeap;
+   Write ('Allocating ',Blocks,' blocks at the end of the heap: ');
    Start := MSTimer;
-   FOR L := 1 TO 10000 DO BEGIN
+   FOR L := 1 TO Blocks DO BEGIN
       GetMem (BlkPtr [L], BlkSize [L]);
    END;
    Delta := MSTimer-Start-LoopTime;
    Inc (TotalTime, Delta);
    WriteLn (Delta:5, ' ms');
-   WriteLn ('MaxAvail: ', MaxAvail, '   MemAvail: ', MemAvail);
-   FOR L := 1 TO 10000 DO BEGIN
+   ShowHeap;
+   FOR L := 1 TO Blocks DO BEGIN
       Permutation [L] := L;
    END;
    Start := MSTimer;
-   FOR L := 10000 DOWNTO 1 DO BEGIN
+   FOR L := Blocks DOWNTO 1 DO BEGIN
       Choice := Random (L)+1;
       K := Permutation [Choice];
       Permutation [Choice] := Permutation [L];
    END;
    LoopTime2 := MSTimer - Start;
-   FOR L := 1 TO 10000 DO BEGIN
+   FOR L := 1 TO Blocks DO BEGIN
       Permutation [L] := L;
    END;
-   Write ('Deallocating same 10000 blocks at random:       ');
+   Write ('Deallocating same ',Blocks,' blocks at random:       ');
    Start := MSTimer;
-   FOR L := 10000 DOWNTO 1 DO BEGIN
+   FOR L := Blocks DOWNTO 1 DO BEGIN
       Choice := Random (L)+1;
       K := Permutation [Choice];
       Permutation [Choice] := Permutation [L];
@@ -90,21 +104,21 @@ BEGIN
    Delta := MSTimer - Start - LoopTime2;
    Inc (TotalTime, Delta);
    WriteLn (Delta:5, ' ms');
-   WriteLn ('MaxAvail: ', MaxAvail, '   MemAvail: ', MemAvail);
-   Write ('Allocating 10000 blocks at the end of the heap: ');
+   ShowHeap;
+   Write ('Allocating ',Blocks,' blocks at the end of the heap: ');
    Start := MSTimer;
-   FOR L := 1 TO 10000 DO BEGIN
+   FOR L := 1 TO Blocks DO BEGIN
       GetMem (BlkPtr [L], BlkSize [L]);
    END;
    Delta := MSTimer-Start-LoopTime;
    Inc (TotalTime, Delta);
    WriteLn (Delta:5, ' ms');
-   WriteLn ('MaxAvail: ', MaxAvail, '   MemAvail: ', MemAvail);
-   FOR L := 1 TO 10000 DO BEGIN
+   ShowHeap;
+   FOR L := 1 TO Blocks DO BEGIN
       Permutation [L] := L;
    END;
    Start := MSTimer;
-   FOR L := 10000 DOWNTO 1 DO BEGIN
+   FOR L := Blocks DOWNTO 1 DO BEGIN
       Choice := Random (L)+1;
       K := Permutation [Choice];
       T:= Permutation [L];
@@ -112,12 +126,12 @@ BEGIN
       Permutation [Choice] := T;
    END;
    LoopTime2 := MSTimer - Start;
-   FOR L := 1 TO 10000 DO BEGIN
+   FOR L := 1 TO Blocks DO BEGIN
       Permutation [L] := L;
    END;
-   Write ('Deallocating 5000 blocks at random:             ');
+   Write ('Deallocating ',(Blocks div 2 + 1),' blocks at random:             ');
    Start := MSTimer;
-   FOR L := 10000 DOWNTO 5001 DO BEGIN
+   FOR L := Blocks DOWNTO (Blocks div 2 + 1) DO BEGIN
       Choice := Random (L)+1;
       K := Permutation [Choice];
       T:= Permutation [L];
@@ -130,38 +144,38 @@ BEGIN
    WriteLn (Delta:5, ' ms');
    WriteLn ('MaxAvail: ', MaxAvail, '   MemAvail: ', MemAvail);
    Start := MSTimer;
-   FOR L := 1 TO 10000 DO BEGIN
-      Dummy := MaxAvail;
+   FOR L := 1 TO Blocks DO BEGIN
+      MaxAvail;
    END;
    Delta := MSTimer-Start;
    Inc (TotalTime, (Delta + 5) DIV 10);
-   WriteLn ('10000 calls to MaxAvail:                        ', Delta:5, ' ms');
+   WriteLn (Blocks,' calls to MaxAvail:                        ', Delta:5, ' ms');
    Start := MSTimer;
-   FOR L := 1 TO 10000 DO BEGIN
-      Dummy := MemAvail;
+   FOR L := 1 TO Blocks DO BEGIN
+      MemAvail;
    END;
    Delta := MSTimer - Start;
    Inc (TotalTime, (Delta + 5) DIV 10);
-   WriteLn ('10000 calls to MemAvail:                        ', Delta:5, ' ms');
-   WriteLn ('MaxAvail: ', MaxAvail, '   MemAvail: ', MemAvail);
-   Write ('Reallocating deallocated 500 blocks at random: ');
+   WriteLn (Blocks,' calls to MemAvail:                        ', Delta:5, ' ms');
+   ShowHeap;
+   Write ('Reallocating deallocated ',(Blocks div 2 + 1),' blocks at random: ');
    Start := MSTimer;
-   FOR L := 5001 TO 10000 DO BEGIN
+   FOR L := (Blocks div 2+1) TO Blocks DO BEGIN
       GetMem (BlkPtr [Permutation [L]], BlkSize [Permutation [L]]);
    END;
    Delta := MSTimer-Start-LoopTime;
    Inc (TotalTime, Delta);
    WriteLn (Delta:5, ' ms');
-   WriteLn ('MaxAvail: ', MaxAvail, '   MemAvail: ', MemAvail);
-   Write ('Deallocating all 10000 blocks at random:        ');
+   ShowHeap;
+   Write ('Deallocating all ',Blocks,' blocks at random:        ');
    Start := MSTimer;
-   FOR L := 10000 DOWNTO 1 DO BEGIN
+   FOR L := Blocks DOWNTO 1 DO BEGIN
       FreeMem (BlkPtr [L], BlkSize [L]);
    END;
    Delta := MSTimer-Start-LoopTime;
    Inc (TotalTime, Delta);
    WriteLn (Delta:5, ' ms');
-   WriteLn ('MaxAvail: ', MaxAvail, '   MemAvail: ', MemAvail);
+   ShowHeap;
    WriteLn;
    WriteLn ('Total time for benchmark: ', TotalTime, ' ms');
 END.