Method: Duffy::System.threads

Defined in:
lib/duffy/system.rb

.threadsObject

How many threads does the system have.



33
34
35
36
37
38
39
40
41
# File 'lib/duffy/system.rb', line 33

def threads
  case RUBY_PLATFORM
    when /linux/  then File.read('/proc/cpuinfo').scan(/^processor\s*:/).size
    when /darwin/ then `sysctl -n hw.ncpu`.to_i
    else 1
  end
rescue
  1
end