Class: Evilution::Memory::LeakCheck
- Inherits:
-
Object
- Object
- Evilution::Memory::LeakCheck
- Defined in:
- lib/evilution/memory/leak_check.rb
Constant Summary collapse
- WARMUP_ITERATIONS =
5- DEFAULT_ITERATIONS =
50- DEFAULT_MAX_GROWTH_KB =
10 MB
10_240
Instance Attribute Summary collapse
-
#samples ⇒ Object
readonly
Returns the value of attribute samples.
Instance Method Summary collapse
- #growth_kb ⇒ Object
-
#initialize(iterations: DEFAULT_ITERATIONS, max_growth_kb: DEFAULT_MAX_GROWTH_KB) ⇒ LeakCheck
constructor
A new instance of LeakCheck.
- #passed? ⇒ Boolean
- #rss_available? ⇒ Boolean
- #run ⇒ Object
Constructor Details
#initialize(iterations: DEFAULT_ITERATIONS, max_growth_kb: DEFAULT_MAX_GROWTH_KB) ⇒ LeakCheck
Returns a new instance of LeakCheck.
14 15 16 17 18 |
# File 'lib/evilution/memory/leak_check.rb', line 14 def initialize(iterations: DEFAULT_ITERATIONS, max_growth_kb: DEFAULT_MAX_GROWTH_KB) @iterations = iterations @max_growth_kb = max_growth_kb @samples = [] end |
Instance Attribute Details
#samples ⇒ Object (readonly)
Returns the value of attribute samples.
12 13 14 |
# File 'lib/evilution/memory/leak_check.rb', line 12 def samples @samples end |
Instance Method Details
#growth_kb ⇒ Object
30 31 32 33 34 35 |
# File 'lib/evilution/memory/leak_check.rb', line 30 def growth_kb return nil if samples.any?(&:nil?) return 0 if samples.size < 2 samples.last - samples.first end |
#passed? ⇒ Boolean
37 38 39 40 41 42 |
# File 'lib/evilution/memory/leak_check.rb', line 37 def passed? kb = growth_kb return false if kb.nil? kb <= @max_growth_kb end |
#rss_available? ⇒ Boolean
26 27 28 |
# File 'lib/evilution/memory/leak_check.rb', line 26 def rss_available? !Evilution::Memory.rss_kb.nil? end |
#run ⇒ Object
20 21 22 23 24 |
# File 'lib/evilution/memory/leak_check.rb', line 20 def run(&) warmup(&) measure(&) result end |