CPU Usage Difference Between Code and Task Manager

이현우(Lee Hyunwoo)(hwoofly) 20 Reputation points
2025-09-26T08:49:43.82+00:00

Hello

I am measuring CPU usage of a process using GetProcessTimes, but it often shows lower values than Task Manager.

I understand Task Manager may include CPU time spent on hardware interrupts and DPCs ("System Interrupts").

Could you clarify:

Does Task Manager always include Interrupt and DPC CPU time in its CPU usage?

Is the difference between GetProcessTimes and Task Manager mainly due to Interrupt/DPC usage?

Is there an official Microsoft reference explaining how Task Manager calculates CPU usage, including "System Interrupts"?

Thank you,

Windows for business | Windows Client for IT Pros | Performance | Application technologies and compatibility
0 comments No comments
{count} votes

Answer accepted by question author
  1. Domic Vo 7,830 Reputation points Independent Advisor
    2025-09-26T11:09:36.1566667+00:00

    Dear 이현우,

    Thank you for reaching out with your questions regarding CPU usage measurement discrepancies between GetProcessTimes and Task Manager. We appreciate your attention to detail and your interest in understanding how Windows reports system performance metrics.

    Interrupts and DPCs in Task Manager Yes, Task Manager includes CPU time spent on hardware interrupts and Deferred Procedure Calls (DPCs) under the “System Interrupts” process. This represents time the CPU spends servicing hardware and driver-level events, which is not attributed to any specific user-mode process.

    GetProcessTimes Scope The GetProcessTimes API reports CPU time consumed by a specific process in user mode and kernel mode, but it does not include time spent on interrupts or DPCs, as these are handled outside the context of the process itself.

    Reason for Discrepancy The difference you’re observing is likely due to interrupt/DPC activity, as well as other system-level tasks that Task Manager accounts for globally but are not reflected in per-process APIs like GetProcessTimes.

    1. Official References Microsoft provides documentation on Task Manager and performance counters at the following resources: Task Manager Overview System Interrupts Explained GetProcessTimes API Reference

    If you’re performing detailed performance analysis, we recommend using Performance Monitor (PerfMon) or Windows Performance Recorder (WPR) for deeper insights into system-level CPU usage, including interrupts and DPCs.

    If this guidance proves helpful, feel free to click “Accept Answer” so we know we’re heading in the right direction 😊. And of course, I’m here if you need further clarification or support.

    T&B,

    Domic Vo

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. TaoLi 33,180 Reputation points Independent Advisor
    2025-09-26T12:29:43.8733333+00:00

    Hello, welcome to contact us in the Microsoft Q&A forum.

    This is because Task Manager includes the process's runtime plus system interrupts (hardware interrupts and DPCs). GetProcessTimes only counts the process's time in user and kernel mode, excluding interrupts. Therefore, the value you read in your code will be lower than what you see in Task Manager.

    Therefore, if you need an accurate view of CPU usage, please consult Task Manager.

    Sorry, there is currently no public algorithm in Microsoft documentation

    These are my thoughts and suggestions, and I hope they are helpful.

    0 comments No comments

Your answer

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