class RubyProf::GraphHtmlPrinter
Generates graph profile reports as html. To use the graph html printer:
result = RubyProf.profile do [code to profile] end printer = RubyProf::GraphHtmlPrinter.new(result) printer.print(STDOUT, :min_percent=>0)
The Graph printer takes the following options in its print methods:
Public Instance Methods
create_link(thread, overall_time, method)
click to toggle source
Creates a link to a method. Note that we do not create links to methods which are under the min_percent specified by the user, since they will not be printed out.
# File lib/ruby-prof/printers/graph_html_printer.rb 35 def create_link(thread, overall_time, method) 36 total_percent = (method.total_time/overall_time) * 100 37 if total_percent < min_percent 38 # Just return name 39 h method.full_name 40 else 41 href = '#' + method_href(thread, method) 42 "<a href=\"#{href}\">#{h method.full_name}</a>" 43 end 44 end
file_link(path, linenum)
click to toggle source
# File lib/ruby-prof/printers/graph_html_printer.rb 50 def file_link(path, linenum) 51 if path.nil? 52 "" 53 else 54 srcfile = File.expand_path(path) 55 "<a href=\"file://#{h srcfile}##{linenum}\" title=\"#{h srcfile}:#{linenum}\">#{linenum}</a>" 56 end 57 end
method_href(thread, method)
click to toggle source
# File lib/ruby-prof/printers/graph_html_printer.rb 46 def method_href(thread, method) 47 h(method.full_name.gsub(/[><#\.\?=:]/,"_") + "_" + thread.fiber_id.to_s) 48 end
print(output = STDOUT, options = {})
click to toggle source
# File lib/ruby-prof/printers/graph_html_printer.rb 26 def print(output = STDOUT, options = {}) 27 setup_options(options) 28 output << @erb.result(binding) 29 end
setup_options(options)
click to toggle source
Calls superclass method
# File lib/ruby-prof/printers/graph_html_printer.rb 21 def setup_options(options) 22 super(options) 23 @erb = ERB.new(self.template) 24 end
template()
click to toggle source
# File lib/ruby-prof/printers/graph_html_printer.rb 59 def template 60 open_asset('graph_printer.html.erb') 61 end