app CPU usage is inconsistent with Activity Monitor's User CPU Usage

According to Xcode, my app is using up about 23% of CPU:

This seems consistent with its CPU usage indicated by Activity Monitor:

Now if you look at the bottom section of the Activity Monitor screenshot, you'll see it's indicating about 5% User CPU usage, i.e. "The percentage of CPU capability that’s being used by apps you opened, or by the processes opened by those apps."

This looks incoherent. If the app is taking up 23% CPU, why is User CPU usage 5%?

Hi tallereric,

both numbers look correct, but they refer to different denominators which is why this can be confusing.

An app's CPU usage is measured in terms of "how much of a single CPU core does it use?". That's why the CPU usage of a process in this view can also go above 100%. E.g. 300% CPU usage would mean the process uses as much CPU cycles as 3 CPUs can provide (it might still be running on 6 CPUs for 50% each).

However, the split in System, User and Idle is measured in terms of total CPU cycles the system can provide. You can also see this difference in the Xcode view: The left-most number on the gauge is 1200, indicating that the maximum CPU usage you can have is 1200%. This indicates that the system you are measuring has 12 CPU cores available.

You can now take the 23% of a single CPU the app uses and divide it by 12 to arrive at the share of the system's CPUs the app uses: 23%/12 = 1.9%, which fits into the 5.13% of user CPU usage you see.

app CPU usage is inconsistent with Activity Monitor's User CPU Usage
 
 
Q