How is the process CPU usage in Task Manager calculated

Abraham Alaniz 1 Reputation point
2022-09-09T04:17:10.367+00:00

I'm using PowerShell to attempt to recreate a similar output as seen for the CPU usage in Task Manager under Processes.

What formula is used to get these numbers?

All I've seen is that the counter Process Timer is what's displayed in the Details section for the individual app, while the overall CPU usage is displayed with Processor Utility counter. I understand how and what is used to get the results seen in the Details tab, but how do I get the CPU usage as shown under the process tab for an individual/all apps?

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,504 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 84,286 Reputation points
    2022-09-09T06:36:36.933+00:00

    Task Manager calls NtQueryInformationProcess with ProcessTimes, which is the same thing as GetProcessTimes
    It can also be done with PDH (How To Retrieve Performance Counter Value Using PDH)

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.