1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

CPU usage of a process

Discussion in 'Support' started by element, Jun 21, 2008.

  1. element

    Joined:
    Jun 1, 2008
    Messages:
    30
    Likes Received:
    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?
     
  2. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,716
    Likes Received:
    29
    On Sat, 21 Jun 2008 19:07:17 -0500, you wrote:


    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.
     
  3. element

    Joined:
    Jun 1, 2008
    Messages:
    30
    Likes Received:
    0
    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.
     

Share This Page