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

Florian Klämpfl florian at freepascal.org
Wed May 19 19:42:27 CEST 2021



> Am 19.05.2021 um 19:00 schrieb Bo Berglund via fpc-pascal <fpc-pascal at lists.freepascal.org>:
> 
> On Wed, 19 May 2021 16:02:00 +0200, Bo Berglund via fpc-pascal
> <fpc-pascal at lists.freepascal.org> wrote:
> 
>> The "other" items might be hidden inside other used classes such as the Indy10
>> components I use to implement the TCP/IP communications.
>> But when searching for sleep through the complete project sources I came up
>> empty-handed.
>> Something else must be going on.
>> 
>> I have a thread to handle the measuring sequence server and this uses timers
>> (TFpTimer) in order to check if it is time to run a task, but when idling no
>> task is running so no task execution thread spins off either...
> 
> So now I am down to the timers...
> I am using TFPTimer timers in the scheduler to handle various things, some of
> them are just one-shots to delay an action for some predetarmined time.
> These are only executing as one-shots.
> But the schedule timer restarts itself with an interval of 60 s.
> Another timer is used to handle a message queue between parts of the system. It
> runs at a shorter time, like a second or so. Restarts itself too.
> But it runs only if scheduling is active.
> 
> I have no idea how TFpTimers work internally, maybe these cause extra CPU cycles
> while waiting for the time they should fire?
> I could switch off the scheduling timer, but it made no difference.
> The other timers running for other purposes I canot disable.
> An these fire more often.
> 
> Right now the server is running at 10% when doing nothing, not even checking
> schedules...
> After I did a service restart it drops to about 5%

Even it’s a service, running it with gprof enabled should be possible, no?


More information about the fpc-pascal mailing list