Class: RubyProf::FlameGraphJsonPrinter::FlameDataWalker

Inherits:
Walker
  • Object
show all
Defined in:
lib/ruby-prof/printers/flame_graph_json_printer.rb

Instance Attribute Summary collapse

Attributes inherited from Walker

#min_fraction, #roots

Instance Method Summary collapse

Methods inherited from Walker

#run

Constructor Details

#initialize(output, threads, options = {}) ⇒ FlameDataWalker

Returns a new instance of FlameDataWalker.



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ruby-prof/printers/flame_graph_json_printer.rb', line 46

def initialize(output, threads, options={})
  super(threads, options)
  @output = output

  @printer = FlameDataJsonPrinter.new(@output, {
    depth: 1,
    anchored: false
  })

  @height = 0
  @depth = 0
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



44
45
46
# File 'lib/ruby-prof/printers/flame_graph_json_printer.rb', line 44

def height
  @height
end

#outputObject (readonly)

Returns the value of attribute output.



43
44
45
# File 'lib/ruby-prof/printers/flame_graph_json_printer.rb', line 43

def output
  @output
end

Instance Method Details

#enter_frame(type, obj, name, called, self_value, total_value) ⇒ Object



59
60
61
62
63
# File 'lib/ruby-prof/printers/flame_graph_json_printer.rb', line 59

def enter_frame(type, obj, name, called, self_value, total_value)
  @depth += 1
  @height = @depth if @height < @depth
  @printer.enter(name, called, self_value, total_value)
end

#leave_frame(type, obj) ⇒ Object



65
66
67
68
# File 'lib/ruby-prof/printers/flame_graph_json_printer.rb', line 65

def leave_frame(type, obj)
  @printer.leave
  @depth -= 1
end