class RubyProf::FastCallTreePrinter

Optimized implementation of CallTreePrinter

Public Class Methods

new(result) click to toggle source
# File lib/ruby-prof/printers/fast_call_tree_printer.rb, line 10
def initialize(result)
  @result = result
  @output = nil
end

Public Instance Methods

determine_event_specification_and_value_scale() click to toggle source
# File lib/ruby-prof/printers/fast_call_tree_printer.rb, line 29
def determine_event_specification_and_value_scale
  @value_scales = []
  @event_specifications = ['events:']

  @result.measure_modes.each do |measure_mode|
    case measure_mode
      when RubyProf::PROCESS_TIME
        @value_scales << RubyProf::CLOCKS_PER_SEC
        @event_specifications << 'process_time'
      when RubyProf::WALL_TIME
        @value_scales << 1_000_000
        @event_specifications << 'wall_time'
      when RubyProf.const_defined?(:CPU_TIME) && RubyProf::CPU_TIME
        @value_scales << RubyProf.cpu_frequency
        @event_specifications << 'cpu_time'
      when RubyProf.const_defined?(:ALLOCATIONS) && RubyProf::ALLOCATIONS
        @value_scales << 1
        @event_specifications << 'allocations'
      when RubyProf.const_defined?(:MEMORY) && RubyProf::MEMORY
        @value_scales << 1
        @event_specifications << 'memory'
      when RubyProf.const_defined?(:GC_RUNS) && RubyProf::GC_RUNS
        @value_scales << 1
        @event_specifications << 'gc_runs'
      when RubyProf.const_defined?(:GC_TIME) && RubyProf::GC_TIME
        @value_scales << 1000000
        @event_specifications << 'gc_time'
      else
        raise "Unknown measure mode: #{measure_mode}"
    end
  end
end
print(output = STDOUT, options = {}) click to toggle source

Specify print options.

options - Hash table

:only_threads - list of threads to print
print_headers() click to toggle source
print_threads() click to toggle source
printable_threads() click to toggle source
# File lib/ruby-prof/printers/fast_call_tree_printer.rb, line 70
def printable_threads
  if @options[:only_threads]
    only_thread_ids = @options[:only_threads].map(&:object_id)
    @result.threads.select do |t|
      only_thread_ids.include?(t.id)
    end
  else
    @result.threads
  end
end