Class: PumaAutoTune::Memory
- Inherits:
-
Object
- Object
- PumaAutoTune::Memory
- Defined in:
- lib/puma_auto_tune/memory.rb
Instance Attribute Summary collapse
-
#master ⇒ Object
Returns the value of attribute master.
-
#workers ⇒ Object
Returns the value of attribute workers.
Instance Method Summary collapse
- #amount ⇒ Object
-
#initialize(master = PumaAutoTune::Master.new) ⇒ Memory
constructor
A new instance of Memory.
- #largest_worker ⇒ Object
- #name ⇒ Object
- #reset ⇒ Object
- #smallest_worker ⇒ Object
Constructor Details
#initialize(master = PumaAutoTune::Master.new) ⇒ Memory
Returns a new instance of Memory.
8 9 10 |
# File 'lib/puma_auto_tune/memory.rb', line 8 def initialize(master = PumaAutoTune::Master.new) @master = master end |
Instance Attribute Details
#master ⇒ Object
Returns the value of attribute master.
6 7 8 |
# File 'lib/puma_auto_tune/memory.rb', line 6 def master @master end |
#workers ⇒ Object
Returns the value of attribute workers.
6 7 8 |
# File 'lib/puma_auto_tune/memory.rb', line 6 def workers @workers end |
Instance Method Details
#amount ⇒ Object
16 17 18 19 20 21 |
# File 'lib/puma_auto_tune/memory.rb', line 16 def amount @mb ||= begin worker_memory = workers.map {|w| w.memory }.inject(&:+) || 0 worker_memory + @master.get_memory end end |
#largest_worker ⇒ Object
23 24 25 |
# File 'lib/puma_auto_tune/memory.rb', line 23 def largest_worker workers.last end |
#name ⇒ Object
12 13 14 |
# File 'lib/puma_auto_tune/memory.rb', line 12 def name "resource_ram_mb" end |
#reset ⇒ Object
35 36 37 38 39 |
# File 'lib/puma_auto_tune/memory.rb', line 35 def reset raise "must set master" unless @master @workers = nil @mb = nil end |
#smallest_worker ⇒ Object
27 28 29 |
# File 'lib/puma_auto_tune/memory.rb', line 27 def smallest_worker workers.first end |