Module: Fastlane::Helper::CpuLoadHandler
- Defined in:
- lib/fastlane/plugin/mango/helper/cpu_load_handler.rb
Class Method Summary collapse
-
.cpu_core_amount ⇒ Object
Gets amount of the CPU cores.
-
.cpu_load ⇒ Object
Gets load average of Linux machine.
- .print_cpu_load(load = cpu_load) ⇒ Object
-
.wait_cpu_to_idle ⇒ Object
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.
Class Method Details
.cpu_core_amount ⇒ Object
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_load ⇒ Object
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 |
.print_cpu_load(load = cpu_load) ⇒ Object
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_idle ⇒ Object
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 |