Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

CPU usage of a process

Jun
30
0
I have an application that has an intense startup phase, with CPU usage >50%. The length of this initial phase is unpredictable and varies between a few seconds to about a minute. Once the startup phase is over, the CPU usage for this app drops to 0%. I'd like to execute a command when the startup phase ends. To do this, I want to write a loop that checks the CPU usage of that process every second or so. I tried TCC's tasklist, but it doesn't give me the CPU usage per process. The closest thing I've found is pmon, part of Microsoft's Support Tools. Pmon shows CPU usage per process, but it displays the info on-screen in a continuously updated table, without terminating.

My questions: 1) Is there a way to extract info from commands like pmon, which continuously update their output? 2) If not, is there a another tool/command/technique that can check the CPU usage of a process?
 
On Sat, 21 Jun 2008 19:07:17 -0500, you wrote:


> My questions: 1) Is there a way to extract info from commands like pmon, which continuously update their output? 2) If not, is there a another tool/command/technique that can check the CPU usage of a process?

How CPU usage (in percent) is measured is somehat arbitrary and relies on more
than one observation taken over a period of time.

If you want to see process times themselves, and make some decision on that
info, you could use @PROCTIME[] from

ftp://lucky.syr.edu/4plugins/sysutils.zip


v:\> syshelp @proctime
@PROCTIME[pid|.[,flag]] = process times; '.' = current process; flags:

b begin
r[x] running (x = s|m|h|d, default = s)
k kernel CPU (seconds)
u user CPU
t total CPU

For example, while TCC is busy running this command (which takes about 2.8 sec)

for /l %i in (1,1,10000) echo %@proctime[.,t] | uniq

it's total CPU usage is updated about 120 times and the averall change is about
2.2 sec.

5.4843750
[snipped about 118 observations]
7.6812500

You might conclude that during that time, its average CPU usage was about
2.2/2.8, or about 78%.

Rather than try to compute %-usage over some period of time, you could just get
the times periodically until they stop increasing.
 
On Sat, 21 Jun 2008 19:07:17 -0500, you wrote:
If you want to see process times themselves, and make some decision on that
info, you could use @PROCTIME[]

Thanks for the detailed answer. I'll keep this info for future reference. I was actually able to solve the problem without checking CPU usage. I figured that when the initialization stage ends, some files in the app folder get created or updated. I was right: there's a file that is written to when the init stage ends. I wrote a batch file that launches the app and then checks the access timestamp on that file every second to determine the "age" of the file in seconds. When the age drops to 0, that means that the init stage has just ended. Works great.
 
Back
Top
[FOX] Ultimate Translator
Translate