class RubyProf::CallStackPrinter

Prints a HTML visualization of the call tree.

To use the printer:

result = RubyProf.profile do
  [code to profile]
end

printer = RubyProf::CallStackPrinter.new(result)
printer.print(STDOUT)

Public Instance Methods

application() click to toggle source
    # File lib/ruby-prof/printers/call_stack_printer.rb
173 def application
174   @options[:application] || $PROGRAM_NAME
175 end
arguments() click to toggle source
    # File lib/ruby-prof/printers/call_stack_printer.rb
177 def arguments
178   ARGV.join(' ')
179 end
base64_image() click to toggle source
    # File lib/ruby-prof/printers/call_stack_printer.rb
219 def base64_image
220   file = open_asset('call_stack_printer.png')
221   Base64.encode64(file).gsub(/\n/, '')
222 end
color(p) click to toggle source
    # File lib/ruby-prof/printers/call_stack_printer.rb
160 def color(p)
161   case i = p.to_i
162   when 0..5
163     "01"
164   when 5..10
165     "05"
166   when 100
167     "9"
168   else
169     "#{i/10}"
170   end
171 end
dump(ci) click to toggle source
    # File lib/ruby-prof/printers/call_stack_printer.rb
156 def dump(ci)
157   $stderr.printf "%s/%d t:%f s:%f w:%f  \n", ci, ci.object_id, ci.total_time, ci.self_time, ci.wait_time
158 end
expansion() click to toggle source
    # File lib/ruby-prof/printers/call_stack_printer.rb
189 def expansion
190   @options[:expansion] || 10.0
191 end
method_href(method) click to toggle source
    # File lib/ruby-prof/printers/call_stack_printer.rb
144 def method_href(method)
145   h(method.full_name.gsub(/[><#\.\?=:]/,"_") + "_" + @current_thread_id.to_s)
146 end
name(call_info) click to toggle source
    # File lib/ruby-prof/printers/call_stack_printer.rb
122 def name(call_info)
123   method = call_info.target
124   method.full_name
125 end
open_asset(file) click to toggle source
    # File lib/ruby-prof/printers/call_stack_printer.rb
209 def open_asset(file)
210   path = File.join(File.expand_path('../../assets', __FILE__), file)
211   File.open(path, 'rb').read
212 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.

: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(visited, 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
152 def sum(a)
153   a.inject(0.0){|s,t| s+=t}
154 end
threshold() click to toggle source
    # File lib/ruby-prof/printers/call_stack_printer.rb
185 def threshold
186   @options[:threshold] || 1.0
187 end
title() click to toggle source
    # File lib/ruby-prof/printers/call_stack_printer.rb
181 def title
182   @title ||= @options.delete(:title) || "ruby-prof call tree"
183 end
total_time(call_infos) click to toggle source
    # File lib/ruby-prof/printers/call_stack_printer.rb
148 def total_time(call_infos)
149   sum(call_infos.map{|ci| ci.total_time})
150 end