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