Can I manually limit the %CPU used by a process?
cputhrottle is the tool you need. You can install it with Homebrew.

You can monitor a series of processes by name by running the Bash script below. I'm not quite sure how to turn this into a login item since cputhrottle requires superuser permissions. Run it as a script, in an Automator workflow, whatever:

# Get the Process/App names from Activity Monitor and put them here
apps=("AppOne" "AppTwo" "AppThree")
# Set the respective limits here
limits={30 40 50)

while true; do
  for app in ${apps}; do
    for limit in ${limits}; do
      for pid in $(pgrep ${app}); do
        sudo /path/to/cputhrottle ${pid} ${limit}
      done
    done
  done
done


[Edited]

I've added a different version for this script (a bash script), which might be useful for people looking for limiting the CPU for multiple applications.

This new script also allows you to specify a list containing the application name and the CPU limit for it.

The main difference is that you can add cpu limit per application, and it will run only once per application. I've also added the option for killing all cputhrottle processes.

The script assumes that both cputhrottle and pidof are installed before running it.

#!/bin/bash

if [[ $EUID &gt; 0 ]]; then
  echo "Please run this script as root/sudo"
  exit 1
fi

# Pass --kill as argument to kill all running cputhrottles
if [ $1 = "--kill" ]; then  
  echo "Looking for running cputhrottles..."
  pids=`pidof cputhrottle`
  for pid in ${pids}; do
    echo "&gt; Killing PID ${pid}"
    sudo kill ${pid}
  done
  echo "Done!"
  exit 0
fi

declare -a applications

# Syntax='application;max-cpu'
applications[0]='Chrome;40'
applications[1]='Firefox;50'
applications[2]='pycharm;40'
applications[3]='webstorm;40'
applications[4]='Safari;35'

for i in "${applications[@]}"; do
  app=(${i//;/ })
  app_name=${app[0]}
  cpu_limit=${app[1]}

  printf "\nLooking for ${app_name}...\n"
  pids=`pidof ${app}`
  for pid in ${pids}; do
    echo "&gt; PID=${pid}, CPU=${cpu_limit}"
    sudo cputhrottle ${pid} ${cpu_limit} &amp;
  done
done

printf "\nDone!\n"
echo "Run this script passing '--kill' as argument to remove all cputhrottles."


Source:


https://gist.github.com/golimpio/692145a19666582f84e0e66bb5dd2b2b