class RubyProf::DotPrinter
Generates a graphviz graph in dot format.
To use the dot printer:
result = RubyProf.profile do [code to profile] end printer = RubyProf::DotPrinter.new(result) printer.print(STDOUT)
You can use either dot viewer such as GraphViz, or the dot command line tool to reformat the output into a wide variety of outputs:
dot -Tpng graph.dot > graph.png
Constants
- CLASS_COLOR
- EDGE_COLOR
Public Class Methods
new(result)
click to toggle source
Creates the DotPrinter
using a RubyProf::Proile.
Calls superclass method
RubyProf::AbstractPrinter::new
# File lib/ruby-prof/printers/dot_printer.rb 27 def initialize(result) 28 super(result) 29 @seen_methods = Set.new 30 end
Public Instance Methods
print(output = STDOUT, options = {})
click to toggle source
Print a graph report to the provided output.
output - Any IO object, including STDOUT or a file. The default value is STDOUT.
options - Hash of print options. See setup_options for more information.
When profiling results that cover a large number of method calls it helps to use the :min_percent option, for example:
DotPrinter.new(result).print(STDOUT, :min_percent=>5)
# File lib/ruby-prof/printers/dot_printer.rb 45 def print(output = STDOUT, options = {}) 46 @output = output 47 setup_options(options) 48 49 puts 'digraph "Profile" {' 50 #puts "label=\"#{mode_name} >=#{min_percent}%\\nTotal: #{total_time}\";" 51 puts "labelloc=t;" 52 puts "labeljust=l;" 53 print_threads 54 puts '}' 55 end