CPU usage of a process

Jun 1, 2008
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?
 
May 20, 2008
11,292
95
Syracuse, NY, USA
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.
 
Jun 1, 2008
30
0
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.
 
Similar threads
Thread starter Title Forum Replies Date
G High CPU usage Support 27
C Control Everything CPU usage at startup? Support 7
C CPU Usage Support 12
M CPU Usage Support 28
Juanma Barranquero CPU Usage after suspend Support 5
Joe Caverly CPU Load in StatusBar Support 1
I DIR command combo that hangs with high CPU % Support 8
T Strange CPU value Support 3
D Bad CPU value in status bar Support 2
I shralias causes svchost.exe to use 100% cpu Support 10
cgunhouse NTVDM CPU has encountered an illegal instruction. Support 2
R FOR usage error from TCC but not from CMD Support 16
Joe Caverly START Dialog usage of %_ variables Support 0
Gorlash usage rules ?? Support 2
T bdebugger / ide usage confusion Support 14
A pdir function usage Support 3
B Disk usage and hard links Support 16
epement Youtube videos on Take Command usage Support 4
JohnQSmith RD / RMDIR Usage Support 5
JohnQSmith RECYCLE usage? Support 1
vefatica IDE balloon usage tips Support 4
vefatica SETP usually fails with a 32 bit process Support 4
x13 Check if process is elevated? Support 11
Alpengreis Remaining TCMD background process (v26) ... Support 19
vefatica Tmp files from in-process pipes not deleted Support 6
Jay Sage TASKLIST Command Process Count Support 5
Joe Caverly PSHELL and out-of-process servers Support 2
CWBillow Upgrade process Support 7
Joe Caverly SETP and 32-bit process Support 2
rps V20 In-process pipes problem Support 8
R Fixed Internal ZIP command fails to process multiple files Support 3
C Determine process svchost is running Support 13
fpefpe WAD Python support does not process command line Support 14
M WAD tcmd.exe crashes and leaves an orphaned tcc.exe process Support 6
Stefano Piccardi replace tcc process space? Support 8
Q TCC: (Sys) The process cannot access the file because it is being used by another process. Support 0
D Environment in elevated process Support 1
cgunhouse ProcessMonitor Does Not Work With Quoted Process Name Support 5
cgunhouse ProcessMonitor Does Not Work With Quoted Process Name Support 0
Phileosophos ren /s does not process subdirectories Support 3
T Starting a process blocks TCC window... Support 2
nikbackm Find out when a process has stopped Support 5
N Unable to end tcc.exe process Support 1

Similar threads