Class: RubyProf::FlameGraphJsonPrinter

Inherits:
AbstractPrinter show all
Defined in:
lib/ruby-prof/printers/flame_graph_json_printer.rb

Defined Under Namespace

Classes: FlameDataJsonPrinter, FlameDataWalker

Instance Method Summary collapse

Methods inherited from AbstractPrinter

#initialize, #method_name, #print, #print_file, #print_footer, #print_header, #print_thread, #setup_options, #sort_method

Constructor Details

This class inherits a constructor from RubyProf::AbstractPrinter

Instance Method Details

#min_percentObject



5
6
7
# File 'lib/ruby-prof/printers/flame_graph_json_printer.rb', line 5

def min_percent
  @options[:min_percent] || 0.25
end

#min_self_timeObject



9
10
11
# File 'lib/ruby-prof/printers/flame_graph_json_printer.rb', line 9

def min_self_time
  @options[:min_self_time] || 0.001
end

#only_threadsObject



13
14
15
# File 'lib/ruby-prof/printers/flame_graph_json_printer.rb', line 13

def only_threads
  @options[:only_threads]
end


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ruby-prof/printers/flame_graph_json_printer.rb', line 17

def print_threads
  @threads = @result.threads.dup
  @threads.select! { |t| only_thread_ids.include?(t.id) } if only_threads

  walker = FlameDataWalker.new(@output, @threads, {
    min_percent: min_percent,
    min_self_time: min_self_time
  })

  @output << "{\n"
  @output << "  \"root\": "

  walker.run

  @output << ",\n"
  @output << "  \"depth\": #{walker.height}\n"
  @output << "}"
end