Number of processor on Linux
If you are a C/C++ programmer, and are accustomed with the common build process, you will know the make and install commands.
make && make install
If it is a big project, and the whole build process costs a lot. So you want to build parallelized, adding more jobs, like this:
make -j8 && make install
This will creates 8 jobs at the same time. And the best number of job is the number of CPU processors. How to get the number of processor on Linux platform?
Here is one simple way, the nproc command. Its only purpose is to print the number of processors. The build command now will be like:
make $(nproc) && make install
Of course, you can also use this way:
grep -c processor /proc/cpuinfo
And you can also you lscpu command with grep or awk, like this:
lscpu | awk '{ if ($1 == "CPU(s):") print $2 }'