Class: PmdTester::SystemInfo
- Inherits:
-
Object
- Object
- PmdTester::SystemInfo
- Defined in:
- lib/pmdtester/system_info.rb
Overview
Utility to deal with semantic versions
Instance Method Summary collapse
Instance Method Details
#cpu_info ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pmdtester/system_info.rb', line 20 def cpu_info cpuinfo = File.read('/proc/cpuinfo') cpus = parse_cpuinfo(cpuinfo) model_name = cpus.map { |cpu| cpu[:model_name] }.uniq.join(', ') sockets = cpus.map { |cpu| cpu[:physical_id] }.uniq.count cores = cpus.map { |cpu| cpu[:core_id] }.uniq.count threads = cpus.count "#{model_name} (sockets: #{sockets}, cores: #{cores}, hardware threads: #{threads})" end |
#physical_memory ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/pmdtester/system_info.rb', line 6 def physical_memory meminfo = File.read('/proc/meminfo') mem_total_line = meminfo.lines.find { |line| line.start_with?('MemTotal:') } mem_total_kb = mem_total_line.split[1].to_i # Get the value in kB mem_total_gb = mem_total_kb / 1024.0 / 1024.0 # Convert kB to GB mem_total_gb = mem_total_gb.round(1) "#{mem_total_gb} GB" end |
#uname ⇒ Object
15 16 17 18 |
# File 'lib/pmdtester/system_info.rb', line 15 def uname info = Etc.uname "#{info[:sysname]} #{info[:release]}" end |