Calculating process cpu usage by Python
<p>I'm trying to get (by a pid) the process cpu usage. I did some research about it and I found out that I can calculate it by using the GetSystemTimes() function.
I found the calculation in this link: <a href="http://www.codeproject.com/Articles/10258/How-to-get-CPU-usage-of-processes-and-threads" rel="nofollow">http://www.codeproject.com/Articles/10258/How-to-get-CPU-usage-of-processes-and-threads</a></p>

<p>And I need this code in Python But I don't know how to do this.
So I found this code: <a href="https://sites.google.com/site/cadspython/home/modules/calcprocesscpuusage-py" rel="nofollow">https://sites.google.com/site/cadspython/home/modules/calcprocesscpuusage-py</a></p>

<p>I was trying to run it, and everything was working fine, but when I ran a little Python program (which took 28% from the cpu utilization), the code was showing me 100% and 98%. Which is not good.</p>

<p>So, I am asking for a code which calculate a process cpu usage by using the GetSystemTimes() function in Python (with pywin32).</p>

<p>Thanks in advance.</p>