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_perecent specified by the user, since they will not be printed out.
# File lib/ruby-prof/printers/graph_html_printer.rb, line 35 def create_link(thread, overall_time, method) total_percent = (method.total_time/overall_time) * 100 if total_percent < min_percent # Just return name h method.full_name else href = '#' + method_href(thread, method) "<a href=\"#{href}\">#{h method.full_name}</a>" end end
file_link(path, linenum)
click to toggle source
# File lib/ruby-prof/printers/graph_html_printer.rb, line 50 def file_link(path, linenum) if path.nil? "" else srcfile = File.expand_path(path) "<a href=\"file://#{h srcfile}##{linenum}\" title=\"#{h srcfile}:#{linenum}\">#{linenum}</a>" end end
method_href(thread, method)
click to toggle source
# File lib/ruby-prof/printers/graph_html_printer.rb, line 46 def method_href(thread, method) h(method.full_name.gsub(/[><#\.\?=:]/,"_") + "_" + thread.fiber_id.to_s) end
print(output = STDOUT, options = {})
click to toggle source
# File lib/ruby-prof/printers/graph_html_printer.rb, line 26 def print(output = STDOUT, options = {}) setup_options(options) output << @erb.result(binding) end
setup_options(options)
click to toggle source
Calls superclass method
# File lib/ruby-prof/printers/graph_html_printer.rb, line 21 def setup_options(options) super(options) @erb = ERB.new(self.template) end
template()
click to toggle source
# File lib/ruby-prof/printers/graph_html_printer.rb, line 59 def template open_asset('graph_printer.html.erb') end