-
-
Notifications
You must be signed in to change notification settings - Fork 6
Home
djberg96 edited this page Sep 27, 2011
·
15 revisions
The sys-cpu library provides an interface for gathering information about your system's CPU.
require 'sys/cpu' include Sys puts CPU.architecture # CPU architecture, e.g. "i386". puts CPU.freq # CPU frequency. puts CPU.load_avg # Array containing load average for 1, 5 and 15 minute periods. puts CPU.model # CPU model. puts CPU.machine # CPU class. May be identical to architecture. puts CPU.num_cpu # Number of CPU's (cores).
puts CPU.state(0) # The state of CPU 0 (the default if no arg is provided). puts CPU.cpu_type # The CPU architecture. puts CPU.fpu_type # The type of floating point unit, if any.
The CPU.architecture and CPU.machine methods are not supported on Solaris.
puts CPU.num_active_cpu # The number of active processors on the system.
The CPU.model and CPU.machine methods are not supported on HP-UX.
The CPU.freq method is not supported on OS X.
Also, the CPU.model method doesn't seem to necessarily refer to the model of the CPU so much as the overall hardware model.