[fpc-pascal] How to find where my app consumes CPU?
Martin Frb
lazarus at mfriebe.de
Wed May 19 00:44:18 CEST 2021
On 19/05/2021 00:29, Bo Berglund via fpc-pascal wrote:
>
> While not (bSTerm or bSInt or bsHup) do
> begin
> //Here is where the server runs as defined elsewhere
> //Eternal loop to wait for system messages
> Sleep(1); //To not hog the CPU
> CheckSynchronize; //To get thread comm working
> end;
>
sleep 1 is not that much. How does it change if you increase it to
sleep(50) / just for testing?
Also CheckSyncronize afaik takes a timeout.
So if you do not need to check the variables every millisecond, then do
While not (bSTerm or bSInt or bsHup) do
begin
//Here is where the server runs as defined elsewhere
//Eternal loop to wait for system messages
CheckSynchronize(50); //To get thread comm working
end;
--------
For all, else you can try
valgrind --tool callgrind
and kcachegrind to view the result.
but not sure if that works on a service, maybe you can run your code in a foreground process under valgrind?
More information about the fpc-pascal
mailing list