[fpc-pascal] How to find where my app consumes CPU?

Bo Berglund bo.berglund at gmail.com
Wed May 19 15:30:40 CEST 2021


On Wed, 19 May 2021 00:44:18 +0200, Martin Frb via fpc-pascal
<fpc-pascal at lists.freepascal.org> wrote:

>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;
>

So I tested by changing the loop to:

  While not (bSTerm or bSInt or bsHup) do
  begin
    //Here is where the server runs as defined elsewhere
    //Eternal loop to wait for system msg bSTerm, bSInt or bsHup
    CheckSynchronize(5); //To get thread comm working
  end;

It still worked as before so I can get rid of the sleep() but it still runs at
CPU = 6% while idling.

I guess this "proves" that the main loop is not what is causing this CPU usage.

Next I will search all of the code for instances of sleep() and see if there are
other CPU "thieves" around.


-- 
Bo Berglund
Developer in Sweden



More information about the fpc-pascal mailing list