TAdvRichEditor: performance

Hello,


for many years we have been using a normal TRichEdit to display logging in this form:

[Info][2019-02-15 15:15:14 828]…
[Warning][2019-02-15 15:40:29 174]…
[Error][2019-02-15 15:40:46 393]…

However, on Windows 10 we recently started encountering performance issues (application interface freezes).  Apparently TRichEdit is not the most efficient component, especially when changing data in the beginning (like deleting the first line).

I started doing tests with TMS's TAdvRichEditor to see if we get better performance, but it does not seem to be better: in my tests on my laptop my interface starts freezing at arount 450 messages per second with TRichEdit and already at around 80 messages per second with a TAdvRichEdit.

The code I'm using is:

procedure addMTLogToAdvRe(const aAdvRe: TAdvRichEditor; const s: String; const aLvl: TMTLogLevel; const aLogTime: TDateTime; const aMaxLines: Word);
var
  sNow, sLvl: string;
begin
  aAdvRe.BeginUpdate;
  try
    aAdvRe.AddText(sLvl,MTLogLevelToColor(aLvl));//diplay loglevel
    aAdvRe.AddText(sNow + s);//display time + text
    aAdvRe.AddLineBreak;

    //---limit to (100) lines (NYI for TAdvRichEdit)

    //---scroll down
    aAdvRe.SetCaret(cpEndDoc);
    aAdvRe.ScrollToCaret;
  finally
    aAdvRe.EndUpdate;
  end;
end;

Is there an other component I should be using for this to get better performance, or am I doing something wrong?

The issue here is the time-consuming BeginUpdate/EndUpdate call for every line you add. For each EndUpdate call, a full TAdvRichEditor redraw is invoked. The increase the performance, I'd suggest to buffer messages for a given time, for example 1 second and then add this buffer at once in a BeginUpdate/EndUpdate block. I would not expect the user to notice that the log messages are updated every second.