class RubyProf::CallStackPrinter

prints a HTML visualization of the call tree

Public Instance Methods

application() click to toggle source
# File lib/ruby-prof/printers/call_stack_printer.rb, line 162
def application
  @options[:application] || $PROGRAM_NAME
end
arguments() click to toggle source
# File lib/ruby-prof/printers/call_stack_printer.rb, line 166
def arguments
  ARGV.join(' ')
end
color(p) click to toggle source
# File lib/ruby-prof/printers/call_stack_printer.rb, line 149
def color(p)
  case i = p.to_i
  when 0..5
    "01"
  when 5..10
    "05"
  when 100
    "9"
  else
    "#{i/10}"
  end
end
copy_image_files() click to toggle source
# File lib/ruby-prof/printers/call_stack_printer.rb, line 182
def copy_image_files
  if @output.is_a?(File)
    target_dir = File.dirname(@output.path)
    image_dir = File.join(File.dirname(__FILE__), '..', 'images')
    %w(empty plus minus).each do |img|
      source_file = "#{image_dir}/#{img}.png"
      target_file = "#{target_dir}/#{img}.png"
      FileUtils.cp(source_file, target_file) unless File.exist?(target_file)
    end
  end
end
dump(ci) click to toggle source
# File lib/ruby-prof/printers/call_stack_printer.rb, line 145
def dump(ci)
  $stderr.printf "%s/%d t:%f s:%f w:%f  \n", ci, ci.object_id, ci.total_time, ci.self_time, ci.wait_time
end
expansion() click to toggle source
# File lib/ruby-prof/printers/call_stack_printer.rb, line 178
def expansion
  @options[:expansion] || 10.0
end
method_href(method) click to toggle source
# File lib/ruby-prof/printers/call_stack_printer.rb, line 133
def method_href(method)
  h(method.full_name.gsub(/[><#\.\?=:]/,"_") + "_" + @current_thread_id.to_s)
end
name(call_info) click to toggle source
# File lib/ruby-prof/printers/call_stack_printer.rb, line 107
def name(call_info)
  method = call_info.target
  method.full_name
end
print(output = STDOUT, options = {}) click to toggle source

Specify print options.

options - Hash table

:min_percent - Number 0 to 100 that specifes the minimum
               %self (the methods self time divided by the
               overall total time) that a method must take
               for it to be printed out in the report.
               Default value is 0.

:print_file  - True or false. Specifies if a method's source
               file should be printed.  Default value if false.

:threshold   - a float from 0 to 100 that sets the threshold of
               results displayed.
               Default value is 1.0

:title       - a String to overide the default "ruby-prof call tree"
               title of the report.

:expansion   - a float from 0 to 100 that sets the threshold of
               results that are expanded, if the percent_total
               exceeds it.
               Default value is 10.0

:application - a String to overide the name of the application,
               as it appears on the report.
print_commands() click to toggle source
print_css() click to toggle source
print_header() click to toggle source
print_help() click to toggle source
print_java_script() click to toggle source
print_stack(call_info, parent_time) click to toggle source
print_title_bar() click to toggle source
sum(a) click to toggle source
# File lib/ruby-prof/printers/call_stack_printer.rb, line 141
def sum(a)
  a.inject(0.0){|s,t| s+=t}
end
threshold() click to toggle source
# File lib/ruby-prof/printers/call_stack_printer.rb, line 174
def threshold
  @options[:threshold] || 1.0
end
title() click to toggle source
# File lib/ruby-prof/printers/call_stack_printer.rb, line 170
def title
  @title ||= @options.delete(:title) || "ruby-prof call tree"
end
total_time(call_infos) click to toggle source
# File lib/ruby-prof/printers/call_stack_printer.rb, line 137
def total_time(call_infos)
  sum(call_infos.map{|ci| ci.total_time})
end