Best way to measure CPU usage of a process?

Best way to measure CPU usage of a process?

Post by CHANGE USERNAME to weste » Sat, 10 Jul 1999 04:00:00



The pdh interface to performance monitor let you measure three
process-related attributes to get the CPU usage of a process:

Processor Time
User Time
Privileged Time

What confuses me is that all three of these are given as a *percentage of
elapsed time*.  How can such a value be meaningful in an absolute way?  Some
process may take 2 seconds of CPU time, but elapsed time is always a
variable.  On a heavily loaded system the elapsed time might be 20 seconds.
On an unloaded system elapsed time might be five seconds.  So the pdh
counter is going to give processor time for this process as 10% in the first
case and 40% in the second case, yet the actual amount of CPU time was a
constant for the two cases.

Is there some more reliable way to represent the CPU usage of a process that
would give me a good feel for how much of a machine's resources that process
takes up, expressed as some normalized value?

--
Will

NOTE:   To reply, CHANGE the username to westes AT uscsw.com

 
 
 

Best way to measure CPU usage of a process?

Post by CHANGE USERNAME to weste » Sat, 10 Jul 1999 04:00:00


Actually, that by itself is not any more useful.  Consider that pdh gives me
CPU expressed as a percentage of elapsed time, and it also gives me elapsed
time.  So the product of the two gives me CPU time of my process, which
should be the same values produced by GetProcessTimes()

What I want instead is to know what percentage of the CPU used by *all*
application and kernel processes was attributable to just my application.

--
Will

NOTE:   To reply, CHANGE the username to westes AT uscsw.com


Quote:> Call GetProcessTimes.  This gives you the total times spent in kernel
> and user,  and not a percentage.


 
 
 

Best way to measure CPU usage of a process?

Post by Stev » Sun, 11 Jul 1999 04:00:00


Call GetProcessTimes.  This gives you the total times spent in kernel
and user,  and not a percentage.

Steve

On Fri, 9 Jul 1999 02:52:33 -0700, "CHANGE USERNAME to westes"


>The pdh interface to performance monitor let you measure three
>process-related attributes to get the CPU usage of a process:

>Processor Time
>User Time
>Privileged Time

>What confuses me is that all three of these are given as a *percentage of
>elapsed time*.  How can such a value be meaningful in an absolute way?  Some
>process may take 2 seconds of CPU time, but elapsed time is always a
>variable.  On a heavily loaded system the elapsed time might be 20 seconds.
>On an unloaded system elapsed time might be five seconds.  So the pdh
>counter is going to give processor time for this process as 10% in the first
>case and 40% in the second case, yet the actual amount of CPU time was a
>constant for the two cases.

>Is there some more reliable way to represent the CPU usage of a process that
>would give me a good feel for how much of a machine's resources that process
>takes up, expressed as some normalized value?

>--
>Will

>NOTE:   To reply, CHANGE the username to westes AT uscsw.com

 
 
 

Best way to measure CPU usage of a process?

Post by Stev » Mon, 12 Jul 1999 04:00:00


As I understand it,  the the system keeps track of the amount of time
spent exectuting each process.  This value is divided into two parts.
User and Kernel times.

For the most part,  the sum of User and Kernel will be the total time
the CPU has spent executing you process.

There will be some additional time by the System process, csrss,  and
maybe a few others.  If you application uses resources supplied by
other processes (eg MAPI),  then that would be another.

The system does not track what percentage of the time spent executing
a process was due to a second process.  So there is no way to know how
much additional CPU time was used due to your process.

Steve

On Fri, 9 Jul 1999 23:49:22 -0700, "CHANGE USERNAME to westes"


>Actually, that by itself is not any more useful.  Consider that pdh gives me
>CPU expressed as a percentage of elapsed time, and it also gives me elapsed
>time.  So the product of the two gives me CPU time of my process, which
>should be the same values produced by GetProcessTimes()

>What I want instead is to know what percentage of the CPU used by *all*
>application and kernel processes was attributable to just my application.

>--
>Will

>NOTE:   To reply, CHANGE the username to westes AT uscsw.com



>> Call GetProcessTimes.  This gives you the total times spent in kernel
>> and user,  and not a percentage.

 
 
 

Best way to measure CPU usage of a process?

Post by CHANGE USERNAME to weste » Tue, 13 Jul 1999 04:00:00


Does the system track the total amount of CPU time used by all processes on
the system during a particular period?

--
Will

NOTE:   To reply, CHANGE the username to westes AT uscsw.com