Method: LinuxStat::ProcessInfo.nproc
- Defined in:
- lib/linux_stat/process_info.rb
.nproc(pid = $$) ⇒ Object Also known as: count_cpu
nproc(pid = $$)
Returns the cpu allocated to the process.
The output value is an Integer.
For example:
$ taskset -c 0 irb
irb(main):001:0> require 'linux_stat'
=> true
irb(main):002:0> LinuxStat::ProcessInfo.nproc
=> 1
irb(main):003:0> LinuxStat::ProcessInfo.nproc 11562
=> 3
irb(main):004:0> LinuxStat::ProcessInfo.nproc 12513
=> 4
If the info isn’t available or the argument passed doesn’t exist as a process ID, it will return nil.
611 612 613 |
# File 'lib/linux_stat/process_info.rb', line 611 def nproc(pid = $$) LinuxStat::Nproc.count_cpu_for_pid(pid) end |