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.



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

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.



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

def children
  @children
end

#lineObject (readonly)

Returns the value of attribute line.



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

def line
  @line
end

#samplesObject

Returns the value of attribute samples.



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

def samples
  @samples
end

#total_samplesObject

Returns the value of attribute total_samples.



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

def total_samples
  @total_samples
end

Instance Method Details

#eachObject



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

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



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

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