Class: HeapProfiler::Analyzer::Dimension

Inherits:
Object
  • Object
show all
Defined in:
lib/heap_profiler/analyzer.rb

Direct Known Subclasses

GroupedDimension

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDimension

Returns a new instance of Dimension.



7
8
9
10
# File 'lib/heap_profiler/analyzer.rb', line 7

def initialize
  @objects = 0
  @memory = 0
end

Instance Attribute Details

#memoryObject (readonly)

Returns the value of attribute memory.



6
7
8
# File 'lib/heap_profiler/analyzer.rb', line 6

def memory
  @memory
end

#objectsObject (readonly)

Returns the value of attribute objects.



6
7
8
# File 'lib/heap_profiler/analyzer.rb', line 6

def objects
  @objects
end

Instance Method Details

#process(_index, object) ⇒ Object



12
13
14
15
# File 'lib/heap_profiler/analyzer.rb', line 12

def process(_index, object)
  @objects += 1
  @memory += object[:memsize]
end

#stats(metric) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/heap_profiler/analyzer.rb', line 17

def stats(metric)
  case metric
  when "objects"
    objects
  when "memory"
    memory
  else
    raise "Invalid metric: #{metric.inspect}"
  end
end