<> <> <> 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.