Class: System::CPU
- Inherits:
-
Object
- Object
- System::CPU
- Defined in:
- lib/system/cpu.rb
Overview
Information about the current CPU(s) running on the current system.
Class Method Summary collapse
-
.count ⇒ Integer
The CPU count of the system, including individual CPU cores.
Class Method Details
.count ⇒ Integer
The CPU count of the system, including individual CPU cores.
14 15 16 17 18 19 20 21 |
# File 'lib/system/cpu.rb', line 14 def count return Java::Java.lang.Runtime.getRuntime.availableProcessors if System::Ruby.java? # defined? Java::Java return File.read('/proc/cpuinfo').scan(/^processor\s*:/).size if File.exist?('/proc/cpuinfo') require 'win32ole' WIN32OLE.connect("winmgmts://").ExecQuery("select * from Win32_ComputerSystem").NumberOfProcessors rescue LoadError Integer `sysctl -n hw.ncpu 2>/dev/null` rescue 1 end |