How to see battery consumption per application (!!) over the past X hours on my MacBook


I asked this question a while back: Stop MacBook from using up the battery while it is in sleep mode. And never got to the bottom of it.

I keeps happening, that I put my Mac in sleep (on a full battery), and bring it with me on a train or something – and on that day, the battery-Gods had thrown a curse on me: 10% battery left. SIGH!!

Overarching question: In order to debug this, I'm looking for a way I can figure out, which applications used (the most) energy for the past 12 hours (or so).

I know that it can be misleading, since maybe Chrome spend the most energy/battery, but it was my Docker-service that stopped my Mac from every sleeping (while barely consuming any energy/battery).

Bonus points if you can give me a terminal-command to run for: ‘Kill everything that is stopping my Mac from going into proper sleep'.


Solution attempt 1: Activity Monitor

I can see that there are some information in the Activity Monitor. Such as the column called: 12 hour Power. I assume that is what I'm looking for.

It told me that ‘Spotlight' consumed 73% (in the 12 hour Power-column), the last time this happened. Hmm…

Solution attempt 2: 3rd party application – or a command

I tried looking for a program or a terminal-command, that would get me some extra insight. But I couldn't find anything (that didn't look shady).

Solution attempt 3: Lock screen vs sleep vs hibernate

I read this article here: How to Choose a Sleep Mode for Your Mac, which was good for my understanding, but not revolutionizing anything in my quest here.

The biggest difference after that article was, that I know more about when to use ‘Screen lock':

… and when to use ‘Sleep':

sleep

For context, I'm mentioning that I'm using hibernatemode 3.

Solution attempt 4: Look into pmset

By writing: pmset -g I got some extra info. But nothing that I could use for this particular case:

System-wide power settings:
Currently in use:
 lidwake              1
 lowpowermode         0
 standbydelayhigh     86400
 standbydelaylow      10800
 standby              1
 proximitywake        1
 ttyskeepawake        1
 hibernatemode        3
 powernap             0
 gpuswitch            2
 hibernatefile        /var/vm/sleepimage
 highstandbythreshold 50
 displaysleep         15
 womp                 1
 networkoversleep     0
 sleep                0 (sleep prevented by nfsd, sharingd, useractivityd)
 tcpkeepalive         1
 halfdim              1
 acwake               0
 disksleep            0

As can be seen there, it says: (sleep prevented by nfsd, sharingd, useractivityd).

sharingd

By Googling sharingd I can see that that is used by AirDrop. I read about sharingd – and then disabled AirDrop.

useractivityd

I don't know what this is. But it disappears by itself, if I simply run pmset -g again and again.

nfsd

This I know quite a bit about, since when I played with Vagrant. It's the Network File System Daemon. One can read more about it with the command: man nfsd.

I stopped that with: sudo nfsd stop (it can be started simply with a reboot or with: sudo nfsd start). It's what handles sync'ing of files to a Vagrant Virtual machine – and maybe also to a Docker container (I'm assuming the last bit here).


After having gone through this, then pmset -g doesn't display any programs nor daemons ‘preventing sleep'.

So now I'll try, if I know that battery will be important, to run pmset -g and see if any service is preventing sleep (and also checking that column in the Activity Monitor). And trying to kill those applications first.

But I would still love to get some graphs over which applications used how much energy/battery, of the past X hours.

Author: Subham

Leave a Reply

Your email address will not be published. Required fields are marked *