[Lazarus] Memo.Lines.Add seems to be slow with Lazarus 1.6

Werner Pamler werner.pamler at freenet.de
Wed Nov 2 16:56:08 CET 2016


I tested on Win 10 (using the code of the first post in this thread):

- 23 sec on Laz trunk / fpc 3.0
- 23 sec on Laz 1.6 / fpc 3.0
- 23 sec Laz trunk / fpc 2.6.4
- 2.2 sec on Laz 1.44 / fpc 2.6.4
- 1.4 sec on Delphi Berlin 10.1

Using Lazarus trunk I could get a good boost by adding the strings first 
to a separate stringlist which is then assigned to the memo's Lines: 1.1 
sec:

procedure TForm1.Button1Click(Sender: TObject);
var
    i: Integer;
    s: String;
    Start, Stop: DWord;
    L: TStrings;
begin
    s:= 
'01234567890123456789012345678901234567890123456789012345678901234567890123456789';
    L := TStringList.Create;
    try
      for i:=1 to 10000 do L.Add(s);
      Start := GetTickCount;
      Memo1.Lines.BeginUpdate;
      Memo1.Lines.Assign(L);
      Memo1.Lines.EndUpdate;
      Stop := GetTickCount;
      ShowMessage(IntToStr(Stop - Start) + ' ms');
    finally
      L.Free;
    end;
end;


More information about the Lazarus mailing list