Sha256: bbfa9685b7b80ca8f55b0915371739f875cd5b049bd4ac06821e82429390a1c0

Contents?: true

Size: 1.61 KB

Versions: 32

Compression:

Stored size: 1.61 KB

Contents

# encoding: utf-8

module RubyProf
  # Prints out the call graph based on CallTree instances. This
  # is mainly for debugging purposes as it provides access into
  # into RubyProf's internals.
  #
  # To use the printer:
  #
  #   result = RubyProf.profile do
  #     [code to profile]
  #   end
  #
  #   printer = RubyProf::CallInfoPrinter.new(result)
  #   printer.print(STDOUT)
  class CallInfoPrinter < AbstractPrinter
    TIME_WIDTH = 0

    private

    def print_header(thread)
      @output << "----------------------------------------------------\n"
      @output << "Thread ID: #{thread.id}\n"
      @output << "Fiber ID: #{thread.fiber_id}\n"
      @output << "Total Time: #{thread.total_time}\n"
      @output << "Sort by: #{sort_method}\n"
      @output << "\n"
    end

    def print_methods(thread)
      visitor = CallTreeVisitor.new(thread.call_tree)

      visitor.visit do |call_tree, event|
        if event == :enter
          @output << "  " * call_tree.depth
          @output << call_tree.target.full_name
          @output << " ("
          @output << "tt:#{sprintf("%#{TIME_WIDTH}.2f", call_tree.total_time)}, "
          @output << "st:#{sprintf("%#{TIME_WIDTH}.2f", call_tree.self_time)}, "
          @output << "wt:#{sprintf("%#{TIME_WIDTH}.2f", call_tree.wait_time)}, "
          @output << "ct:#{sprintf("%#{TIME_WIDTH}.2f", call_tree.children_time)}, "
          @output << "call:#{call_tree.called}, "
          @output << ")"
          @output << "\n"
        end
      end
    end

    def print_footer(thread)
      @output << "\n" << "\n"
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
ruby-prof-1.7.1-x64-mingw-ucrt lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.7.1 lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.7.0-x64-mingw-ucrt lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.7.0 lib/ruby-prof/printers/call_info_printer.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/ruby-prof-1.6.3/lib/ruby-prof/printers/call_info_printer.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/ruby-prof-1.6.3/lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.6.3-x64-mingw-ucrt lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.6.3 lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.6.2-x64-mingw-ucrt lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.6.2 lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.6.1 lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.6.1-x64-mingw-ucrt lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.5.0-x64-mingw-ucrt lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.5.0 lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.4.5-x64-mingw-ucrt lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.4.5 lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.4.4-x64-mingw-ucrt lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.4.4 lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.4.3-x64-mingw32 lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.4.3 lib/ruby-prof/printers/call_info_printer.rb