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.
12 13 14 15 16 |
# File 'lib/evilution/memory/leak_check.rb', line 12 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.
10 11 12 |
# File 'lib/evilution/memory/leak_check.rb', line 10 def samples @samples end |
Instance Method Details
#growth_kb ⇒ Object
28 29 30 31 32 33 |
# File 'lib/evilution/memory/leak_check.rb', line 28 def growth_kb return nil if samples.any?(&:nil?) return 0 if samples.size < 2 samples.last - samples.first end |
#passed? ⇒ Boolean
35 36 37 38 39 40 |
# File 'lib/evilution/memory/leak_check.rb', line 35 def passed? kb = growth_kb return false if kb.nil? kb <= @max_growth_kb end |
#rss_available? ⇒ Boolean
24 25 26 |
# File 'lib/evilution/memory/leak_check.rb', line 24 def rss_available? !Evilution::Memory.rss_kb.nil? end |
#run ⇒ Object
18 19 20 21 22 |
# File 'lib/evilution/memory/leak_check.rb', line 18 def run(&) warmup(&) measure(&) result end |