If you want to run a command that you know is going to use quite a bit of CPU but you don’t want it to completely take over your system there is a really neat utility that can help you out. It’s called cpulimit and it does exactly what you think it would.
The basic usage is this:
cpulimit -l XX command
where XX is the CPU % you want to limit the process to and command is the process you want to run. So for example let’s say you wanted Firefox to only ever use 30% of your CPU you would simply start it from a terminal like this:
cpulimit -l 30 firefox
You can even limit it based on CPU cores instead of overall CPU usage if you want using the -c flag instead of the -l flag.
If you want more advanced features you could use something like cgroups but for simple stuff cpulimit seems to work very well.