home *** CD-ROM | disk | FTP | other *** search
- PROGRAM OptimumPageSize;
-
- TYPE
- PageInfo =
- RECORD
- Bytes : Integer;
- NumRecs : Integer;
- Unused : Integer
- END;
-
- VAR
- Pages : ARRAY [1 .. 8] OF PageInfo;
- Best : Byte;
- NumDupKeys : Integer;
- Loc : Integer;
- RecByteLen : Integer;
-
- BEGIN { OptimumPageSize }
- FillChar (Pages, SizeOf (Pages), 0);
- Write ('Enter record length in bytes : ');
- ReadLn (RecByteLen);
- Write ('Enter number of duplicate keys : ');
- ReadLn (NumDupKeys);
- FOR Loc := 1 TO 8 DO
- WITH Pages[Loc] DO
- BEGIN
- Bytes := 512 * Loc;
- NumRecs := (Bytes - 6) DIV (RecByteLen + 8 * NumDupKeys);
- Unused := Bytes - 6 - (NumRecs * (RecByteLen + 8 * NumDupKeys) )
- END;
- Best := 1;
- FOR Loc := 1 TO 7 DO
- IF Pages[Best].Unused > Pages[Loc + 1].Unused THEN
- Best := Loc + 1;
- WriteLn;
- WITH Pages[Best] DO
- WriteLn ('Best fit is ', Bytes, ' with ', NumRecs, ' records and only ', Unused, ' unused bytes');
- WriteLn;
- FOR Loc := 1 TO 8 DO
- WITH Pages[Loc] DO
- WriteLn ('Page ', Bytes:4, ' Records ', NumRecs:4, ' unused bytes ', Unused:4)
- END { OptimumPageSize }.