Search code examples
batch-filecpu-usagetasklist

How to convert a tasklist's CPU time to CPU % usage?


I'm trying to use tasklist to find out which process is consuming more than X percent of my CPU (to later kill it with taskkill.)

How do I know what percent a time format represents?

The documentations says:

TASKLIST options

/FI   filter               

And one filter may be:

CPUTIME         eq, ne, gt, lt, ge, le        CPU time in the format: hh:mm:ss.
                                              hh - number of hours,
                                              mm - minutes, ss - seconds

If I try

tasklist /FI "CPUTIME gt 00:00:10" 

it works.

But if I

tasklist /FI "CPUTIME gt 90"

it doesn't.

How can I know that time format represent 90%? Or 80%? What's the relationship between CPU usage time and the CPU usage percent?


Solution

  • Tasklist's CPUTime is a measure of how much CPU time (cycles) have been used since the start of the process, so to convert that to a percent, it would be

     (TotalProcessRuntime / CpuTime) / 100
    

    At least, thats what I gather :)