mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 16:09:25 +02:00
* reduce counters for sparc
This commit is contained in:
parent
c99d93c90b
commit
056201180f
@ -5,6 +5,14 @@
|
|||||||
}
|
}
|
||||||
PROGRAM TestHeap;
|
PROGRAM TestHeap;
|
||||||
|
|
||||||
|
|
||||||
|
const
|
||||||
|
{$ifdef cpusparc}
|
||||||
|
Blocks = 1000;
|
||||||
|
{$else}
|
||||||
|
Blocks = 10000;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
Procedure InitMSTimer;
|
Procedure InitMSTimer;
|
||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
@ -18,12 +26,18 @@ begin
|
|||||||
end;
|
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;
|
Delta, TotalTime: LONGINT;
|
||||||
L,Choice,K,T: WORD;
|
L,Choice,K,T: WORD;
|
||||||
BlkPtr: ARRAY [1..10000] OF POINTER;
|
BlkPtr: ARRAY [1..Blocks] OF POINTER;
|
||||||
BlkSize: ARRAY [1..10000] OF WORD;
|
BlkSize: ARRAY [1..Blocks] OF WORD;
|
||||||
Permutation: ARRAY [1..10000] OF WORD;
|
Permutation: ARRAY [1..Blocks] OF WORD;
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
INitMSTimer;
|
INitMSTimer;
|
||||||
@ -31,57 +45,57 @@ BEGIN
|
|||||||
WriteLn;
|
WriteLn;
|
||||||
TotalTime := 0;
|
TotalTime := 0;
|
||||||
RandSeed := 997;
|
RandSeed := 997;
|
||||||
WriteLn ('MaxAvail: ', MaxAvail, ' MemAvail: ', MemAvail);
|
ShowHeap;
|
||||||
Start :=MSTimer;
|
Start :=MSTimer;
|
||||||
FOR L := 1 TO 10000 DO BEGIN
|
FOR L := 1 TO Blocks DO BEGIN
|
||||||
END;
|
END;
|
||||||
LoopTime := MSTimer-Start;
|
LoopTime := MSTimer-Start;
|
||||||
FOR L := 1 TO 10000 DO BEGIN
|
FOR L := 1 TO Blocks DO BEGIN
|
||||||
BlkSize [L] := Random (512) + 1;
|
BlkSize [L] := Random (512) + 1;
|
||||||
END;
|
END;
|
||||||
Write ('Allocating 10000 blocks at the end of the heap: ');
|
Write ('Allocating ',Blocks,' blocks at the end of the heap: ');
|
||||||
Start := MSTImer;
|
Start := MSTImer;
|
||||||
FOR L := 1 TO 10000 DO BEGIN
|
FOR L := 1 TO Blocks DO BEGIN
|
||||||
GetMem (BlkPtr [L], BlkSize [L]);
|
GetMem (BlkPtr [L], BlkSize [L]);
|
||||||
END;
|
END;
|
||||||
Delta := MSTimer-Start-LoopTime;
|
Delta := MSTimer-Start-LoopTime;
|
||||||
Inc (TotalTime, Delta);
|
Inc (TotalTime, Delta);
|
||||||
WriteLn (Delta:5, ' ms');
|
WriteLn (Delta:5, ' ms');
|
||||||
WriteLn ('MaxAvail: ', MaxAvail, ' MemAvail: ', MemAvail);
|
ShowHeap;
|
||||||
Write ('Deallocating same 10000 blocks in reverse order:');
|
Write ('Deallocating same ',Blocks,' blocks in reverse order:');
|
||||||
Start := MSTimer;
|
Start := MSTimer;
|
||||||
FOR L := 1 TO 10000 DO BEGIN
|
FOR L := 1 TO Blocks DO BEGIN
|
||||||
FreeMem (BlkPtr [L], BlkSize [L]);
|
FreeMem (BlkPtr [L], BlkSize [L]);
|
||||||
END;
|
END;
|
||||||
Delta := MSTimer-Start-LoopTime;
|
Delta := MSTimer-Start-LoopTime;
|
||||||
Inc (TotalTime, Delta);
|
Inc (TotalTime, Delta);
|
||||||
WriteLn (Delta:5, ' ms');
|
WriteLn (Delta:5, ' ms');
|
||||||
WriteLn ('MaxAvail: ', MaxAvail, ' MemAvail: ', MemAvail);
|
ShowHeap;
|
||||||
Write ('Allocating 10000 blocks at the end of the heap: ');
|
Write ('Allocating ',Blocks,' blocks at the end of the heap: ');
|
||||||
Start := MSTimer;
|
Start := MSTimer;
|
||||||
FOR L := 1 TO 10000 DO BEGIN
|
FOR L := 1 TO Blocks DO BEGIN
|
||||||
GetMem (BlkPtr [L], BlkSize [L]);
|
GetMem (BlkPtr [L], BlkSize [L]);
|
||||||
END;
|
END;
|
||||||
Delta := MSTimer-Start-LoopTime;
|
Delta := MSTimer-Start-LoopTime;
|
||||||
Inc (TotalTime, Delta);
|
Inc (TotalTime, Delta);
|
||||||
WriteLn (Delta:5, ' ms');
|
WriteLn (Delta:5, ' ms');
|
||||||
WriteLn ('MaxAvail: ', MaxAvail, ' MemAvail: ', MemAvail);
|
ShowHeap;
|
||||||
FOR L := 1 TO 10000 DO BEGIN
|
FOR L := 1 TO Blocks DO BEGIN
|
||||||
Permutation [L] := L;
|
Permutation [L] := L;
|
||||||
END;
|
END;
|
||||||
Start := MSTimer;
|
Start := MSTimer;
|
||||||
FOR L := 10000 DOWNTO 1 DO BEGIN
|
FOR L := Blocks DOWNTO 1 DO BEGIN
|
||||||
Choice := Random (L)+1;
|
Choice := Random (L)+1;
|
||||||
K := Permutation [Choice];
|
K := Permutation [Choice];
|
||||||
Permutation [Choice] := Permutation [L];
|
Permutation [Choice] := Permutation [L];
|
||||||
END;
|
END;
|
||||||
LoopTime2 := MSTimer - Start;
|
LoopTime2 := MSTimer - Start;
|
||||||
FOR L := 1 TO 10000 DO BEGIN
|
FOR L := 1 TO Blocks DO BEGIN
|
||||||
Permutation [L] := L;
|
Permutation [L] := L;
|
||||||
END;
|
END;
|
||||||
Write ('Deallocating same 10000 blocks at random: ');
|
Write ('Deallocating same ',Blocks,' blocks at random: ');
|
||||||
Start := MSTimer;
|
Start := MSTimer;
|
||||||
FOR L := 10000 DOWNTO 1 DO BEGIN
|
FOR L := Blocks DOWNTO 1 DO BEGIN
|
||||||
Choice := Random (L)+1;
|
Choice := Random (L)+1;
|
||||||
K := Permutation [Choice];
|
K := Permutation [Choice];
|
||||||
Permutation [Choice] := Permutation [L];
|
Permutation [Choice] := Permutation [L];
|
||||||
@ -90,21 +104,21 @@ BEGIN
|
|||||||
Delta := MSTimer - Start - LoopTime2;
|
Delta := MSTimer - Start - LoopTime2;
|
||||||
Inc (TotalTime, Delta);
|
Inc (TotalTime, Delta);
|
||||||
WriteLn (Delta:5, ' ms');
|
WriteLn (Delta:5, ' ms');
|
||||||
WriteLn ('MaxAvail: ', MaxAvail, ' MemAvail: ', MemAvail);
|
ShowHeap;
|
||||||
Write ('Allocating 10000 blocks at the end of the heap: ');
|
Write ('Allocating ',Blocks,' blocks at the end of the heap: ');
|
||||||
Start := MSTimer;
|
Start := MSTimer;
|
||||||
FOR L := 1 TO 10000 DO BEGIN
|
FOR L := 1 TO Blocks DO BEGIN
|
||||||
GetMem (BlkPtr [L], BlkSize [L]);
|
GetMem (BlkPtr [L], BlkSize [L]);
|
||||||
END;
|
END;
|
||||||
Delta := MSTimer-Start-LoopTime;
|
Delta := MSTimer-Start-LoopTime;
|
||||||
Inc (TotalTime, Delta);
|
Inc (TotalTime, Delta);
|
||||||
WriteLn (Delta:5, ' ms');
|
WriteLn (Delta:5, ' ms');
|
||||||
WriteLn ('MaxAvail: ', MaxAvail, ' MemAvail: ', MemAvail);
|
ShowHeap;
|
||||||
FOR L := 1 TO 10000 DO BEGIN
|
FOR L := 1 TO Blocks DO BEGIN
|
||||||
Permutation [L] := L;
|
Permutation [L] := L;
|
||||||
END;
|
END;
|
||||||
Start := MSTimer;
|
Start := MSTimer;
|
||||||
FOR L := 10000 DOWNTO 1 DO BEGIN
|
FOR L := Blocks DOWNTO 1 DO BEGIN
|
||||||
Choice := Random (L)+1;
|
Choice := Random (L)+1;
|
||||||
K := Permutation [Choice];
|
K := Permutation [Choice];
|
||||||
T:= Permutation [L];
|
T:= Permutation [L];
|
||||||
@ -112,12 +126,12 @@ BEGIN
|
|||||||
Permutation [Choice] := T;
|
Permutation [Choice] := T;
|
||||||
END;
|
END;
|
||||||
LoopTime2 := MSTimer - Start;
|
LoopTime2 := MSTimer - Start;
|
||||||
FOR L := 1 TO 10000 DO BEGIN
|
FOR L := 1 TO Blocks DO BEGIN
|
||||||
Permutation [L] := L;
|
Permutation [L] := L;
|
||||||
END;
|
END;
|
||||||
Write ('Deallocating 5000 blocks at random: ');
|
Write ('Deallocating ',(Blocks div 2 + 1),' blocks at random: ');
|
||||||
Start := MSTimer;
|
Start := MSTimer;
|
||||||
FOR L := 10000 DOWNTO 5001 DO BEGIN
|
FOR L := Blocks DOWNTO (Blocks div 2 + 1) DO BEGIN
|
||||||
Choice := Random (L)+1;
|
Choice := Random (L)+1;
|
||||||
K := Permutation [Choice];
|
K := Permutation [Choice];
|
||||||
T:= Permutation [L];
|
T:= Permutation [L];
|
||||||
@ -130,38 +144,38 @@ BEGIN
|
|||||||
WriteLn (Delta:5, ' ms');
|
WriteLn (Delta:5, ' ms');
|
||||||
WriteLn ('MaxAvail: ', MaxAvail, ' MemAvail: ', MemAvail);
|
WriteLn ('MaxAvail: ', MaxAvail, ' MemAvail: ', MemAvail);
|
||||||
Start := MSTimer;
|
Start := MSTimer;
|
||||||
FOR L := 1 TO 10000 DO BEGIN
|
FOR L := 1 TO Blocks DO BEGIN
|
||||||
Dummy := MaxAvail;
|
MaxAvail;
|
||||||
END;
|
END;
|
||||||
Delta := MSTimer-Start;
|
Delta := MSTimer-Start;
|
||||||
Inc (TotalTime, (Delta + 5) DIV 10);
|
Inc (TotalTime, (Delta + 5) DIV 10);
|
||||||
WriteLn ('10000 calls to MaxAvail: ', Delta:5, ' ms');
|
WriteLn (Blocks,' calls to MaxAvail: ', Delta:5, ' ms');
|
||||||
Start := MSTimer;
|
Start := MSTimer;
|
||||||
FOR L := 1 TO 10000 DO BEGIN
|
FOR L := 1 TO Blocks DO BEGIN
|
||||||
Dummy := MemAvail;
|
MemAvail;
|
||||||
END;
|
END;
|
||||||
Delta := MSTimer - Start;
|
Delta := MSTimer - Start;
|
||||||
Inc (TotalTime, (Delta + 5) DIV 10);
|
Inc (TotalTime, (Delta + 5) DIV 10);
|
||||||
WriteLn ('10000 calls to MemAvail: ', Delta:5, ' ms');
|
WriteLn (Blocks,' calls to MemAvail: ', Delta:5, ' ms');
|
||||||
WriteLn ('MaxAvail: ', MaxAvail, ' MemAvail: ', MemAvail);
|
ShowHeap;
|
||||||
Write ('Reallocating deallocated 500 blocks at random: ');
|
Write ('Reallocating deallocated ',(Blocks div 2 + 1),' blocks at random: ');
|
||||||
Start := MSTimer;
|
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]]);
|
GetMem (BlkPtr [Permutation [L]], BlkSize [Permutation [L]]);
|
||||||
END;
|
END;
|
||||||
Delta := MSTimer-Start-LoopTime;
|
Delta := MSTimer-Start-LoopTime;
|
||||||
Inc (TotalTime, Delta);
|
Inc (TotalTime, Delta);
|
||||||
WriteLn (Delta:5, ' ms');
|
WriteLn (Delta:5, ' ms');
|
||||||
WriteLn ('MaxAvail: ', MaxAvail, ' MemAvail: ', MemAvail);
|
ShowHeap;
|
||||||
Write ('Deallocating all 10000 blocks at random: ');
|
Write ('Deallocating all ',Blocks,' blocks at random: ');
|
||||||
Start := MSTimer;
|
Start := MSTimer;
|
||||||
FOR L := 10000 DOWNTO 1 DO BEGIN
|
FOR L := Blocks DOWNTO 1 DO BEGIN
|
||||||
FreeMem (BlkPtr [L], BlkSize [L]);
|
FreeMem (BlkPtr [L], BlkSize [L]);
|
||||||
END;
|
END;
|
||||||
Delta := MSTimer-Start-LoopTime;
|
Delta := MSTimer-Start-LoopTime;
|
||||||
Inc (TotalTime, Delta);
|
Inc (TotalTime, Delta);
|
||||||
WriteLn (Delta:5, ' ms');
|
WriteLn (Delta:5, ' ms');
|
||||||
WriteLn ('MaxAvail: ', MaxAvail, ' MemAvail: ', MemAvail);
|
ShowHeap;
|
||||||
WriteLn;
|
WriteLn;
|
||||||
WriteLn ('Total time for benchmark: ', TotalTime, ' ms');
|
WriteLn ('Total time for benchmark: ', TotalTime, ' ms');
|
||||||
END.
|
END.
|
||||||
|
Loading…
Reference in New Issue
Block a user