Monitoring CPU Usage on Mac from Terminal with a better top command
Following the CPU usage on my Mac is a mild obsession, and I usually use the Mac terminal command ‘top’ to do this but I noticed that top itself takes up a fair amount of CPU usage (5% or more). I made this complaint to a friend of mine and they told me to try this variation of the top command instead, which actually causes the top command to use less CPU, making it a bit more helpful and less of an impact on the overall system. This is great if you run top all the time like me.
Here’s the command syntax to use with top, it runs more efficient, and offers more accurate results for some users. This works in Mac OS X and linux too if you happen to be a crossplatformer.
top -F -R -o cpu
Type that in the Terminal and you’ll get a more efficient usage of top that uses less CPU itself, thanks to the flags.
Since it’s helpful to know what you’re entering and it’s impact on the command syntax, here’s an explanation of the flags in use with this variation of top:
-F Do not calculate statistics on shared libraries, also known as frameworks.
-R Do not traverse and report the memory object map for each process.
-o cpu Order by CPU usage
By using top with those flags I have reduced top CPU usage to 1% and it’s also more appropriate for my needs. Try it out!
You can also just simplify things with sorting by cpu alone, but without the -F and -R flags it will continue to calculate frameworks and memory objects, which is not necessarily helpful or actionable.