Add render throttle to decouple parse throughput from GDI overhead
During bulk serial data flow, renders are capped at ~20fps (50ms interval) so the ANSI parser can run at full speed without blocking on FlipToScreen. When idle, renders immediately for interactive responsiveness. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
75d598c4c5
commit
64b3962c59
1 changed files with 19 additions and 7 deletions
|
|
@ -165,13 +165,18 @@ end;
|
||||||
|
|
||||||
|
|
||||||
procedure TMainForm.Run;
|
procedure TMainForm.Run;
|
||||||
|
const
|
||||||
|
RenderMs = 50; { Minimum ms between renders during bulk flow (20 fps) }
|
||||||
var
|
var
|
||||||
Msg: TMsg;
|
Msg: TMsg;
|
||||||
S: string;
|
S: string;
|
||||||
HasData: Boolean;
|
HasData: Boolean;
|
||||||
|
Now: Longint;
|
||||||
|
LastRenderTick: Longint;
|
||||||
begin
|
begin
|
||||||
Show;
|
Show;
|
||||||
FDone := False;
|
FDone := False;
|
||||||
|
LastRenderTick := GetTickCount;
|
||||||
while not FDone do
|
while not FDone do
|
||||||
begin
|
begin
|
||||||
{ Process all pending Windows messages (keyboard, paint, scrollbar) }
|
{ Process all pending Windows messages (keyboard, paint, scrollbar) }
|
||||||
|
|
@ -218,9 +223,16 @@ begin
|
||||||
if FDone then
|
if FDone then
|
||||||
Break;
|
Break;
|
||||||
|
|
||||||
{ Tick blink (dirties rows if interval elapsed), then render }
|
{ Render throttle: during bulk data flow, only render every RenderMs }
|
||||||
|
{ to decouple parse throughput from GDI overhead. When idle, render }
|
||||||
|
{ immediately for interactive responsiveness. }
|
||||||
|
Now := GetTickCount;
|
||||||
|
if (not HasData) or (Now - LastRenderTick >= RenderMs) then
|
||||||
|
begin
|
||||||
FAnsi.TickBlink;
|
FAnsi.TickBlink;
|
||||||
FAnsi.FlipToScreen;
|
FAnsi.FlipToScreen;
|
||||||
|
LastRenderTick := Now;
|
||||||
|
end;
|
||||||
|
|
||||||
{ Yield CPU to other apps when no serial data is flowing. }
|
{ Yield CPU to other apps when no serial data is flowing. }
|
||||||
{ PM_NOYIELD keeps message draining fast; Yield here gives other }
|
{ PM_NOYIELD keeps message draining fast; Yield here gives other }
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue