Since I have an expert at hand here: What would I have to change to get the 'rock bottom' version?marcov wrote:as alternative going to rock bottom pointer to char handling.
Code: Select all
program RecallFPC; // simple example
uses
Classes, SysUtils, DateUtils, Crt; // FB example (includes MB example; 10ms loading, 2.6 searching)
var
Str: TStringList;
ct, mypos, matches: LongInt;
D1, D2: TDateTime;
begin
Str := TStringList.Create;
write(ParamStr(1)+': loading ');
D1:=Now;
Str.LoadFromFile(ParamStr(1));
D2:=Now;
Writeln(IntToStr(Str.Count)+' strings took ', MilliSecondsBetween(D1, D2), ' milliseconds');
Write('finding ');
D1:=Now;
repeat
//writeln(Str[ct]);
mypos:=Pos('Devil', Str[ct]);
if (mypos>0) then matches:=matches+1;
ct:=ct+1;
until ct>=Str.Count-1;
D2:=Now;
Writeln(IntToStr(matches)+' matches took ', MilliSecondsBetween(D1, D2), ' milliseconds');
Str.Free;
ReadKey;
end.