home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
PASCAL
/
PERFORM
/
TESTSET.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-03-28
|
4KB
|
128 lines
{$IFDEF VER70}
{$A+,B-,D+,E-,F-,G-,I-,L+,N-,O-,P-,Q-,R-,S+,T-,V-,X+}
{$ELSE}
{$A+,B-,D+,E-,F-,G-,I-,L+,N-,O-,R-,S+,V-,X+}
{$ENDIF}
{$M 16384,0,655360}
var TimerTick: Word absolute $0040:$006C;
StartTick: Word;
Reps,Normaliseer: LongInt;
Type CharSet = Set of Char;
Var CSet: CharSet;
Buffer: Array[1..32767] of Char;
i: Integer;
C: Char;
function InSet(var _Set; OrdEl: Byte): Boolean;
var __Set: Array[0..31] of Byte absolute _Set;
begin
InSet := Boolean((__Set[OrdEl SHR 3] SHR (OrdEl AND $07)) AND $01)
end {InSet};
function InSet25(var _Set; OrdElement: Byte): Boolean;
{ Deze inline macro is sneller dan de normale 'in', behalve
indien gebruik wordt gemaakt van 'small sets' die uit 16
elementen of minder bestaan.
}
InLine(
$58/ { pop AX }
$30/$E4/ { xor AH,AH }
$5F/ { pop DI }
$07/ { pop ES }
$89/$C3/ { mov BX,AX }
$B1/$03/ { mov CL,3 }
$D3/$EB/ { shr BX,CL }
$88/$C1/ { mov CL,AL }
$80/$E1/$07/ { and CL,$07 }
$B0/$01/ { mov AL,1 }
$D2/$E0/ { shl AL,CL }
$26/ { ES: }
$22/$01/ { and AL,BYTE PTR [DI+BX] }
$D2/$E8); { shr AL,CL }
begin
CSet := ['b','o','l','e','s','i','a','n'];
for i:=1 to SizeOf(Buffer) do
begin
Buffer[i] := Char(Ord('a')+Random(26)); { Init Buffer }
if (Buffer[i] in CSet) <> InSet25(CSet,Ord(Buffer[i])) then { Error }
begin
writeln('Error InSet25 ',Buffer[i],' not correct at: ',i);
Halt(1)
end;
if (Buffer[i] in CSet) <> InSet(CSet,Ord(Buffer[i])) then { Error }
begin
writeln('Error InSet ',Buffer[i],' not correct at: ',i);
Halt(1)
end
end;
i := 0;
Reps := 0;
StartTick := TimerTick;
while StartTick = TimerTick do {wait for end of TimerTick};
StartTick := TimerTick;
repeat
Inc(i);
if InSet(CSet,Ord(Buffer[i])) then Inc(Reps)
else Inc(Reps);
until StartTick <> TimerTick;
Normaliseer := Reps;
i := 0;
Reps := 0;
StartTick := TimerTick;
while StartTick = TimerTick do {wait for end of TimerTick};
StartTick := TimerTick;
repeat
Inc(i);
if Buffer[i] in CSet then Inc(Reps)
else Inc(Reps);
until StartTick <> TimerTick;
writeln('Bob Swart in: ',(100 * Normaliseer) div Reps:8);
writeln('Borland in: 100');
Normaliseer := Reps;
i := 0;
Reps := 0;
StartTick := TimerTick;
while StartTick = TimerTick do {wait for end of TimerTick};
StartTick := TimerTick;
repeat
Inc(i);
C := Buffer[i];
if (C = 'b') or (C = 'o') or (C = 'l') or (C = 'e') or
(C = 's') or (C = 'i') or (C = 'a') or (C = 'n') then Inc(Reps)
else Inc(Reps);
until StartTick <> TimerTick;
writeln('Borland if: ',(100 * Reps) div Normaliseer:10);
i := 0;
Reps := 0;
StartTick := TimerTick;
while StartTick = TimerTick do {wait for end of TimerTick};
StartTick := TimerTick;
repeat
Inc(i);
C := Buffer[i];
case C of
'b','o','l','e','s','i','a','n': Inc(Reps);
else Inc(Reps);
end;
until StartTick <> TimerTick;
writeln('Borland case: ',(100 * Reps) div Normaliseer:8);
i := 0;
Reps := 0;
StartTick := TimerTick;
while StartTick = TimerTick do {wait for end of TimerTick};
StartTick := TimerTick;
repeat
Inc(i);
if InSet25(CSet,Ord(Buffer[i])) then Inc(Reps)
else Inc(Reps);
until StartTick <> TimerTick;
writeln('Bob Swart 25: ',(100 * Reps) div Normaliseer:8)
end.