Module: Fastlane::Helper::CpuLoadHandler

Defined in:
lib/fastlane/plugin/mango/helper/cpu_load_handler.rb

Class Method Summary collapse

Class Method Details

.cpu_core_amountObject

Gets amount of the CPU cores



17
18
19
# File 'lib/fastlane/plugin/mango/helper/cpu_load_handler.rb', line 17

def self.cpu_core_amount
  Actions.sh("cat /proc/cpuinfo | awk '/^processor/{print $3}' | tail -1")
end

.cpu_loadObject

Gets load average of Linux machine



11
12
13
14
# File 'lib/fastlane/plugin/mango/helper/cpu_load_handler.rb', line 11

def self.cpu_load
  load = Actions.sh('cat /proc/loadavg')
  load.split(' ').first.to_f unless load.empty?
end


6
7
8
# File 'lib/fastlane/plugin/mango/helper/cpu_load_handler.rb', line 6

def self.print_cpu_load(load = cpu_load)
  UI.important("CPU load is: #{load}") if load
end

.wait_cpu_to_idleObject

For half an hour waiting until CPU load average is less than number of cores*2 (which considers that CPU is ready) Raises when 30 minutes timeout exceeds



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fastlane/plugin/mango/helper/cpu_load_handler.rb', line 23

def self.wait_cpu_to_idle
  if OS.linux?
    30.times do
      load = cpu_load
      return true if load <= cpu_core_amount.to_i * 1.5

      print_cpu_load(load)
      UI.important('Waiting for available resources..')
      sleep 60
    end
  else
    return true
  end
  raise "CPU was overloaded. Couldn't start emulator"
end