MacOS – Any app or script to track per process usage

activity-monitormacosprocessor

I am running a process and I want to track it's CPU usage and in the end I would like to have a graph of time vs CPU usage. Any app or script for that? I googled and I couldn't find any. And activity monitor does not give graph of over the time of the process.

Best Answer

You could also use a shell command like this:

while :;do ps -p 1234 -o %cpu=;sleep 1;done

Replace 1234 with the pid of the process.

You can use gnuplot to create a graph for the data:

gnuplot<<<'set term png;set output "/tmp/plot.png";plot "/tmp/data" with boxes'
qlmanage -p /tmp/plot.png