Sha256: 1f8c3e8099d35b23f606a9c14a5995c7124a5db44086b8da055db7fc6e52999c

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

# encoding: utf-8

module RubyProf
  # Prints out the call graph based on CallInfo 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 << "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 = CallInfoVisitor.new(thread.root_methods)

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

    def print_footer(thread)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-prof-1.1.0-x64-mingw32 lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.1.0 lib/ruby-prof/printers/call_info_printer.rb
ruby-prof-1.0.0 lib/ruby-prof/printers/call_info_printer.rb