3 Answers
3

There are many aspects of CPU utilization that affect energy consumption. It's not merely how much CPU does an application consume, but also how often and how flexible it is about it. The latter can have much bigger effect.

An application that needs to wake up exactly every 10ms to execute just a few lines of simple Obj-C code can have an order of magnitude larger energy impact than the same application executing thousands of lines of code but just once a second and not being very particular about exactly when within that second will the calculation happen.

Apple probably uses Intel's performance counters and accounts them to your application. You'd probably gain most insight by following Intel manuals first to understand the power states and energy management. This will highly vary between architectures. A badly behaving app can have a much bigger impact on Haswell than on an "old" Core 2 machine.

Use of other resources, such as the audio system, doing disk I/O or using USB devices may be also factored in. A likely accounting method would assign to your application all of the energy use needed by the resources your application uses exclusively (say a custom USB device, access to an otherwise powered-down audio syste), and do some sort of pro-rating for shared hardware.

Using the above information on per Application and the resulting cumulative Power usage Apple has implemented the Timer Coalescing and the App Nap features to manage Power consumption resulting in the Chart below.

Since the CPU control's activity including RAM management and disk read/writes,Network Card and others for example improving RAM management also reduces power consumption that occurs by to frequent disk R/W activity.

There are many aspects of power management, and they are a combination of very accurate measurement and software designs to reduce the power consumption.

There doesn't seem to be any documentation on how the power consumption is calculated. The CPU usage alone cannot reliably predict power consumption. So the primary factors considered would be (these are somewhat complementary to what App Nap looks at and controls):

CPU usage

Disk input/output

Network input/output

Peripheral use (like audio speakers, for example)

Again, there are no details on how each of these factors are measured and the formulas used to calculate the power consumption. We can make some educated guesses by the fact that every Mac (and also PC) comes equipped with various sensors within the system. You can use a tool like Hardware Monitor to see what sensors your Mac has and what they're reporting in real time.

The key sensors related to power consumption that are available (and have been for several years) in Hardware Monitor are CPU Voltage, CPU Current and CPU Power. For other elements in the above list, there are no hardware sensors to measure power consumption. So Apple must be using specific extrapolation factors depending on the model of the Mac and the underlying hardware.