[fpc-devel] TStringList

Евгений Аксянов evaksianov at mail.ru
Fri Feb 4 11:59:32 CET 2005


Hello.

I have to ask a little question about FreePascal. It's a trouble with a TStringList class. The next code was tested with a 3Mb text file and it works very fast with Delphi (dcc32.exe from the Delphi7). But when this code was compiled by fpc.exe (1.9.5 version was used) it works at about 200 seconds. At the same time, TStringList and TFileStream classes in Delphi and FreePascal realisations are very similar. I ask you about, why this code works such slow and can I make it faster.

Thanks, 
  Evgeniy.

{$ifdef fpc}
 {$mode delphi}
 {$H+} // this option can be On or Off 
       //  but the speed is always very small
{$endif}

program SLTest;

{$ifndef fpc}
 {$apptype console}
{$endif}
uses Classes, SysUtils, DateUtils;

var S: string;
    SL: TStringList;
    T: TDateTime;

begin
  if ParamCount > 0 then
    S:=ParamStr(1)
    else begin
    write('Enter a file name: ');
    readln(S);
    end;

  T:=now;
  SL:=TStringLIst.Create;
  try
   SL.LoadFromFile(S);
  finally
   SL.Free;
  end;

  writeln(inttostr(SecondsBetween(T,now))+' seconds for a work');
end.




More information about the fpc-devel mailing list