Class: Evilution::Memory::LeakCheck Private

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/memory/leak_check.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

WARMUP_ITERATIONS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

5
DEFAULT_ITERATIONS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

50
DEFAULT_MAX_GROWTH_KB =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

10 MB

10_240

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(iterations: DEFAULT_ITERATIONS, max_growth_kb: DEFAULT_MAX_GROWTH_KB) ⇒ LeakCheck

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

#samplesObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/evilution/memory/leak_check.rb', line 10

def samples
  @samples
end

Instance Method Details

#growth_kbObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


24
25
26
# File 'lib/evilution/memory/leak_check.rb', line 24

def rss_available?
  !Evilution::Memory.rss_kb.nil?
end

#runObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
21
22
# File 'lib/evilution/memory/leak_check.rb', line 18

def run(&)
  warmup(&)
  measure(&)
  result
end