Class: Leaks::RAMUsage

Inherits:
Object
  • Object
show all
Defined in:
lib/leaks/ram_usage.rb

Instance Method Summary collapse

Constructor Details

#initializeRAMUsage

Returns a new instance of RAMUsage.



3
4
5
6
7
8
# File 'lib/leaks/ram_usage.rb', line 3

def initialize
  @current   = kilobytes_used
  @highest   = @current
  @stable    = Time.now
  @increased = false
end

Instance Method Details

#currentObject



25
26
27
# File 'lib/leaks/ram_usage.rb', line 25

def current
  @current
end

#increased?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/leaks/ram_usage.rb', line 21

def increased?
  @increased
end

#stable_forObject



33
34
35
# File 'lib/leaks/ram_usage.rb', line 33

def stable_for
  (Time.now - @stable).to_i
end

#to_sObject



29
30
31
# File 'lib/leaks/ram_usage.rb', line 29

def to_s
  "Current: #{current}KB Highest: #{@highest}KB"
end

#updateObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/leaks/ram_usage.rb', line 10

def update
  @increased = false
  @current   = kilobytes_used

  if @current > @highest
    @highest   = @current
    @increased = true
    @stable    = Time.now
  end
end