class Snapshot::CPUInspector

Public Class Methods

cpu_count() click to toggle source
# File snapshot/lib/snapshot/simulator_launchers/simulator_launcher.rb, line 10
def self.cpu_count
  @cpu_count ||=
    case RUBY_PLATFORM
    when /darwin9/
      `hwprefs cpu_count`.to_i
    when /darwin10/
      (hwprefs_available? ? `hwprefs thread_count` : `sysctl -n hw.physicalcpu_max`).to_i
    when /linux/
      UI.user_error!("We detected that you are running snapshot on Linux, but snapshot is only supported on macOS")
    when /freebsd/
      UI.user_error!("We detected that you are running snapshot on FreeBSD, but snapshot is only supported on macOS")
    else
      if RbConfig::CONFIG['host_os'] =~ /darwin/
        (hwprefs_available? ? `hwprefs thread_count` : `sysctl -n hw.physicalcpu_max`).to_i
      else
        UI.crash!("Cannot find the machine's processor count.")
      end
    end
end
hwprefs_available?() click to toggle source
# File snapshot/lib/snapshot/simulator_launchers/simulator_launcher.rb, line 6
def self.hwprefs_available?
  `which hwprefs` != ''
end