TestSweepCollectableStorage.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Robert Hagmann February 19, 1985 5:09:26 pm PST
DIRECTORY
Allocator,
BasicTime ,
Commander USING [CommandProc, Handle, Register],
IO,
Rope,
SafeStorage,
SweepCollectableStorage,
VM;
TestSweepCollectableStorage: PROGRAM
IMPORTS BasicTime, Commander, IO, SweepCollectableStorage
=
BEGIN
ROPE: TYPE = Rope.ROPE;
objectCount, freeObjects, size4, size6, size8: INT;
notMatchs: INT;
firstTypeMiss: BOOL;
fromParm, fromObject: SafeStorage.Type;
perObject: SweepCollectableStorage.InfoProc = {
objectCount ← objectCount + 1;
IF type = SafeStorage.nullType THEN freeObjects ← freeObjects + 1 ;
SELECT size FROM
4 => size4 ← size4 + 1;
6 => size6 ← size6 + 1;
8 => size8 ← size8 + 1;
ENDCASE;
IF objectHP.type ~= type AND firstTypeMiss THEN {
firstTypeMiss ← FALSE;
fromParm ← type;
fromObject ← objectHP.type ;
};
IF (size = 4 AND objectHP.blockSizeIndex ~= 0) THEN notMatchs ← notMatchs + 1 ;
RETURN[TRUE];
};
TestSweepCollectableStorage: Commander.CommandProc = TRUSTED {
startTime: BasicTime.GMT;
timeInSeconds: INT;
objectCount ← 0 ;
freeObjects ← 0 ;
size4 ← 0;
size6 ← 0;
size8 ← 0;
notMatchs ← 0;
firstTypeMiss ← TRUE;
startTime ← BasicTime.Now[];
SweepCollectableStorage.EnumerateCollectableStorage[perObject];
timeInSeconds ← BasicTime.Period[from: startTime, to: BasicTime.Now[]];
IO.PutF[cmd.out, "Total objects: %g, total time: %g seconds\n", IO.int[objectCount], IO.int[timeInSeconds]];
IO.PutF[cmd.out, "Total free: %g, total size 4: %g, total size 6: %g, total size 8: %g\n", IO.int[freeObjects], IO.int[size4], IO.int[size6], IO.int[size8]];
IF notMatchs > 0 THEN IO.PutF[cmd.out, "Total notMatchs: %g\n", IO.int[notMatchs]];
IF ~firstTypeMiss THEN ERROR;
};
Commander.Register[key: "TestSweepCollectableStorage", proc: TestSweepCollectableStorage,
doc: "TestSweepCollectableStorage"];
END.