Class: MacSystemProcessors

Inherits:
SystemProcessors show all
Defined in:
lib/processors.rb

Overview

Processor probe for Mac systems noinspection RubyTooManyInstanceVariablesInspection

Constant Summary

Constants inherited from SystemProcessors

SystemProcessors::UNLIMITED

Instance Attribute Summary

Attributes inherited from SystemProcessors

#architecture, #core_count, #count, #family, #l2_cache, #l3_cache, #manufacturer, #model, #model_name, #speed, #thread_count

Instance Method Summary collapse

Methods inherited from SystemProcessors

probe

Constructor Details

#initializeMacSystemProcessors

Returns a new instance of MacSystemProcessors.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/processors.rb', line 60

def initialize
  # noinspection RubyResolve
  proc = sysctl(HardwareCategory::PROCESSORS)
  @model = proc['model']
  @speed = proc['cpufrequency'].to_i / 1_000_000
  @family = proc['family']
  @architecture = 'x86_64' if proc['cpu64bit_capable'] == '1'
  @count = `system_profiler SPHardwareDataType | grep Processors: | sed -e 's/ *Number of Processors: //'`.to_i
  @core_count = proc['core_count'].to_i * @count
  @thread_count = proc['thread_count'].to_i * @count
  @l2_cache = `system_profiler SPHardwareDataType | grep 'L2 Cache' | sed -e 's/ *L2 Cache (per Core): //'`
  @l2_cache = @l2_cache.to_i * @core_count
  @l3_cache = `system_profiler SPHardwareDataType | grep 'L3 Cache' | sed -e 's/ *L3 Cache: //'`.to_i * 1024
  @manufacturer = proc['vendor']
  @model_name = proc['brand_string']
end