Xojo Conferences
MBSOct2019CologneDE

Way to get cpu usage of a program? (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: getting frontmost application
Next thread: WebDAV


Way to get cpu usage of a program?   -   Colin Cornaby
  Re: Way to get cpu usage of a program?   -   Didier Barbas

Way to get cpu usage of a program?
Date: 08.05.02 00:54 (Tue, 07 May 2002 16:54:09 -0700)
From: Colin Cornaby
What's the best way to get the cpu usage of a program in X? This is
something I need to do in my program. Thanks!

--Colin Cornaby

---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>

Re: Way to get cpu usage of a program?
Date: 08.05.02 01:39 (Wed, 08 May 2002 09:39:12 +0900)
From: Didier Barbas
On 5/8/02 8:54 AM, "Colin Cornaby" <<email address removed>> wrote:

> What's the best way to get the cpu usage of a program in X? This is
> something I need to do in my program. Thanks!
>
> --Colin Cornaby

At 10:34 PM +0900 2/16/02, Didier BARBAS wrote:
>With top -w -ln1 | egrep <process name>, a shell command will return one
>line, which, put into a timer, for instance, will help you see whether the
>memory figures change with time.
>Mac OS X's top version is a little different from the one I have on my Linux
>server, but anyway, just look at the RPRVT, RSHRD, RSIZE and VSIZE figures.
>If they inflate, you might have a leak.
>Note:
>
>RPRVT - amount of resident memory consumed by heap allocations
>RSHRD - amount of resident shared memory (shared libraries)
>RSIZE - more or less equals RPRVT + RSHRD
>VSIZE - the total amount of memory consumed by the process (resident and
>paged memory combined)
>
>HTH

Hence the use of the archives...
The infor output by top is:
PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE VSIZE
Basically, you just need to retrieve the result of the execution of this
shell command, and get the 3rd parameter.
Put that into a timer, and you'll have a real-time (almost) display of the
CPU usage.