# File lib/os.rb, line 224
  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.ncpu`).to_i
    when /linux/
      `cat /proc/cpuinfo | grep processor | wc -l`.to_i
    when /freebsd/
      `sysctl -n hw.ncpu`.to_i
    else
      if RbConfig::CONFIG['host_os'] =~ /darwin/
         (hwprefs_available? ? `hwprefs thread_count` : `sysctl -n hw.ncpu`).to_i
      elsif self.windows?
        # ENV counts hyper threaded...not good.

              # out = ENV['NUMBER_OF_PROCESSORS'].to_i

        require 'win32ole'
        wmi = WIN32OLE.connect("winmgmts://")
        cpu = wmi.ExecQuery("select NumberOfCores from Win32_Processor") # don't count hyper-threaded in this

        cpu.to_enum.first.NumberOfCores
      else
        raise 'unknown platform processor_count'
      end
    end
  end