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

Bernd Mueller mueller.b at gmx.net
Wed Nov 2 13:27:04 CET 2016


Hello,

with Lazarus 1.6 (FPC 3.0.0 i386-linux-gtk 2) filling a Memo with 10000 
lines takes about 18 seconds on my system. Doing the same with Lazarus 
1.4.0 (FPC 2.6.4 i386-linux-gtk 2) takes about 193 ms. I cannot believe, 
that Lazarus 1.6 should be nearly 90 times slower than 1.4.0.

I am wondering, if this is a bug or by design?

Regards, Bernd.

unit Unit1;
{$mode objfpc}{$H+}
interface

uses
    Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, 
StdCtrls, LCLIntf;

type
    { TForm1 }
    TForm1 = class(TForm)
       Button1: TButton;
       Memo1: TMemo;
       procedure Button1Click(Sender: TObject);
    private
       { private declarations }
    public
       { public declarations }
    end;

var
    Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }

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


More information about the Lazarus mailing list