Class: ObjectSpace::AllocationSampler::Result::Frame

Inherits:
Frame
  • Object
show all
Includes:
Enumerable
Defined in:
lib/allocation_sampler.rb

Instance Attribute Summary collapse

Attributes inherited from Frame

#id, #name, #path

Instance Method Summary collapse

Constructor Details

#initialize(frame, line, samples) ⇒ Frame

Returns a new instance of Frame.



28
29
30
31
32
33
34
# File 'lib/allocation_sampler.rb', line 28

def initialize frame, line, samples
  super(frame)
  @line = line
  @samples = samples
  @total_samples = 0
  @children = Set.new
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



23
24
25
# File 'lib/allocation_sampler.rb', line 23

def children
  @children
end

#lineObject (readonly)

Returns the value of attribute line.



23
24
25
# File 'lib/allocation_sampler.rb', line 23

def line
  @line
end

#samplesObject

Returns the value of attribute samples.



24
25
26
# File 'lib/allocation_sampler.rb', line 24

def samples
  @samples
end

#total_samplesObject

Returns the value of attribute total_samples.



24
25
26
# File 'lib/allocation_sampler.rb', line 24

def total_samples
  @total_samples
end

Instance Method Details

#eachObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/allocation_sampler.rb', line 36

def each
  seen = {}
  stack = [self]

  while node = stack.pop
    next if seen[node]
    seen[node] = true
    yield node
    stack.concat node.children.to_a
  end
end

#to_dotObject



48
49
50
51
52
# File 'lib/allocation_sampler.rb', line 48

def to_dot
  seen = {}
  "digraph allocations {\n" +
    "  node[shape=record];\n" + print_edges(self, seen, total_samples) + "}\n"
end