Move some helper functions into Hardware

This commit is contained in:
Adam Vandenberg 2009-11-16 09:35:19 -08:00
parent 83fc432eab
commit 4fbcf13e65
2 changed files with 16 additions and 8 deletions

View File

@ -60,10 +60,24 @@ class Hardware
@@processor_count ||= `/usr/sbin/sysctl -n hw.ncpu`.to_i
end
def self.cores_as_words
case Hardware.processor_count
when 1 then 'single'
when 2 then 'dual'
when 4 then 'quad'
else
Hardware.processor_count
end
end
def self.is_64_bit?
self.sysctl_bool("hw.cpu64bit_capable")
end
def self.bits
Hardware.is_64_bit? ? 64 : 32
end
protected
def self.sysctl_bool(property)
result = nil

View File

@ -42,14 +42,8 @@ end
def dump_config
require 'hardware'
bits = Hardware.is_64_bit? ? 64 : 32
cores = case Hardware.processor_count
when 1 then 'single'
when 2 then 'dual'
when 4 then 'quad'
else
Hardware.processor_count
end
bits = Hardware.bits
cores = Hardware.cores_as_words
llvm = llvm_build
sha = `git rev-parse --verify HEAD`.chomp
kernel_arch = `uname -m`.chomp