get system cpu count in ruby

ruby, system, cpu, count, get

cpu_count = nproc --all.to_i

main.rb

In the code above, we are using the system command `nproc` with the `--all` flag to get the total number of processing units (CPUs/cores) available in the system. The output of the command is then converted to an integer and stored in `cpu_count` variable.
258 chars
3 lines

related categories

gistlibby LogSnag