|
Posted by Vipul Pathak on March 21, 2008, 11:30 am
Please log in for more thread options Thanks Paul ...
In order to get the CPU usage in percentage, I will be using the following
Algorithm:
T1, T2, Tn are threads of their respective processes P1, P2, Pn etc.
=========================================
Time_P1 = (GetThreadTimes(T1)+GetThreadTimes(T2)+ ..... GetThreadTimes(Tn))
;
Time_P2 = (GetThreadTimes(T1)+GetThreadTimes(T2)+ ..... GetThreadTimes(Tn))
;
.
.
.
Time_Pn = (GetThreadTimes(T1)+GetThreadTimes(T2)+ ..... GetThreadTimes(Tn))
;
Total Time Consumed (lets call this: TTC) = Time_P1 + Time_P2 + ...... +
Time_Pn ;
CPU Usage for P1 = (Time_P1 / TTC) * 100 ;
CPU Usage for P2 = (Time_P2 / TTC) * 100 ;
.
.
.
CPU Usage for Pn = (Time_Pn / TTC) * 100 ;
=========================================
If you or any one else think, that this should be corrected, please let me
know.
Thanks,
*(Vipul)() ;
"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
> There's no way to get "battery usage" for a process. That doesn't make
> sense.
>
> As for CPU, look at GetThreadTimes() and add up the times for all threads
> in each process.
>
> Paul T.
>
>> Hello Everyone,
>>
>> I am designing a Task Manager for Windows Mobile Smartphone. I am using
>> CreateToolhelp32Snapshot() to gether process information. I have an
>> additional need to including CPU usage and Battery consumption by every
>> process.
>>
>> Does any one has an Idea of how to detect CPU Usage and Battery Usage by
>> a given process on the Device ?
>>
>> Thanks in Advance,
>>
>> *(Vipul)() ;
>>
>>
>
>
|