Skip to content

Instantly share code, notes, and snippets.

@bsnux
Last active November 8, 2021 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bsnux/d7a7262ea8a42d55a3940820b43e0ca8 to your computer and use it in GitHub Desktop.
Save bsnux/d7a7262ea8a42d55a3940820b43e0ca8 to your computer and use it in GitHub Desktop.
Getting number or CPU processors

Getting number of CPU processors in different languages

ruby -retc -e 'puts Etc.nprocessors'
python -c "import multiprocessing; print(multiprocessing.cpu_count())"
groovy -e "println Runtime.getRuntime().availableProcessors();"
node -e "console.log(os.cpus().length)"
cat /proc/cpuinfo | grep processor | wc -l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment