[Lazarus] Command line program - CPU overused - do I need profiling?
wkitty42 at windstream.net
wkitty42 at windstream.net
Mon Oct 4 14:56:04 CEST 2021
On 10/4/21 4:33 AM, Bo Berglund via lazarus wrote:
> This is the main loop in the program following creatrion of the handler objects (which are idle):
>
QuitSignal:=false;
> While not (bSTerm or bSInt or bsHup) do
While not QuitSignal do
> begin
> //Eternal loop to wait for system messages
> CheckSynchronize(5); //Timeout here instead of using sleep
> if CheckRestartReq then
> begin
> Debug_Writeln('Restart timeout reached - exiting');
> FLogServ.StdLog('Restart timeout reached - exiting');
> break;
> end;
QuitSignal:=(bSTerm or bSInt or bSHup);
> end;
i doubt it will make a difference but what if you adjust the code as shown
above? this puts the while test to check only one item instead of three...
> The while loop breaks on system messages sent by systemd when running as a service or from the keyboard (Ctrl-C) if started in a terminal.
>
> Can this loop by itself cause the 10% CPU usage?
possibly... it depends on what CheckSynchronize and CheckRestartReq are doing...
i don't know of any profilers for command line or service apps... nothing other
than logging with fine timestamps and analyzing the log... this is when i add
debug logging with entry and exit messages logged for each routine and loop...
this allows me to see the code flow and to monitor the time taken in each section...
--
NOTE: No off-list assistance is given without prior approval.
*Please keep mailing list traffic on the list where it belongs!*
More information about the lazarus
mailing list