class RubyProf::MultiPrinter
Helper class to simplify printing profiles of several types from one profiling run. Currently prints a flat profile, a callgrind profile, a call stack profile and a graph profile.
Public Class Methods
needs_dir?()
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb 21 def self.needs_dir? 22 true 23 end
new(result, printers = [:flat, :graph_html])
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb 8 def initialize(result, printers = [:flat, :graph_html]) 9 @flat_printer = FlatPrinter.new(result) if printers.include?(:flat) 10 11 @graph_printer = GraphPrinter.new(result) if printers.include?(:graph) 12 @graph_html_printer = GraphHtmlPrinter.new(result) if printers.include?(:graph_html) 13 14 @tree_printer = CallTreePrinter.new(result) if printers.include?(:tree) 15 @call_info_printer = CallInfoPrinter.new(result) if printers.include?(:call_tree) 16 17 @stack_printer = CallStackPrinter.new(result) if printers.include?(:stack) 18 @dot_printer = DotPrinter.new(result) if printers.include?(:dot) 19 end
Public Instance Methods
call_info_report()
click to toggle source
the name of the callinfo profile file
# File lib/ruby-prof/printers/multi_printer.rb 60 def call_info_report 61 "#{@directory}/#{@profile}.call_tree.txt" 62 end
dot_report()
click to toggle source
the name of the call stack profile file
# File lib/ruby-prof/printers/multi_printer.rb 75 def dot_report 76 "#{@directory}/#{@profile}.dot" 77 end
flat_report()
click to toggle source
the name of the flat profile file
# File lib/ruby-prof/printers/multi_printer.rb 46 def flat_report 47 "#{@directory}/#{@profile}.flat.txt" 48 end
graph_html_report()
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb 55 def graph_html_report 56 "#{@directory}/#{@profile}.graph.html" 57 end
graph_report()
click to toggle source
the name of the graph profile file
# File lib/ruby-prof/printers/multi_printer.rb 51 def graph_report 52 "#{@directory}/#{@profile}.graph.txt" 53 end
print(options)
click to toggle source
create profile files under options or the current directory. options is used as the base name for the profile file, defaults to “profile”.
# File lib/ruby-prof/printers/multi_printer.rb 28 def print(options) 29 validate_print_params(options) 30 31 @profile = options.delete(:profile) || "profile" 32 @directory = options.delete(:path) || File.expand_path(".") 33 34 print_to_flat(options) if @flat_printer 35 36 print_to_graph(options) if @graph_printer 37 print_to_graph_html(options) if @graph_html_printer 38 39 print_to_stack(options) if @stack_printer 40 print_to_call_info(options) if @call_info_printer 41 print_to_tree(options) if @tree_printer 42 print_to_dot(options) if @dot_printer 43 end
print_to_call_info(options)
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb 97 def print_to_call_info(options) 98 File.open(call_info_report, "wb") do |file| 99 @call_info_printer.print(file, options) 100 end 101 end
print_to_dot(options)
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb 113 def print_to_dot(options) 114 File.open(dot_report, "wb") do |file| 115 @dot_printer.print(file, options) 116 end 117 end
print_to_flat(options)
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb 79 def print_to_flat(options) 80 File.open(flat_report, "wb") do |file| 81 @flat_printer.print(file, options) 82 end 83 end
print_to_graph(options)
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb 85 def print_to_graph(options) 86 File.open(graph_report, "wb") do |file| 87 @graph_printer.print(file, options) 88 end 89 end
print_to_graph_html(options)
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb 91 def print_to_graph_html(options) 92 File.open(graph_html_report, "wb") do |file| 93 @graph_html_printer.print(file, options) 94 end 95 end
print_to_stack(options)
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb 107 def print_to_stack(options) 108 File.open(stack_report, "wb") do |file| 109 @stack_printer.print(file, options.merge(:graph => "#{@profile}.graph.html")) 110 end 111 end
print_to_tree(options)
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb 103 def print_to_tree(options) 104 @tree_printer.print(options.merge(:path => @directory, :profile => @profile)) 105 end
stack_report()
click to toggle source
the name of the call stack profile file
# File lib/ruby-prof/printers/multi_printer.rb 70 def stack_report 71 "#{@directory}/#{@profile}.stack.html" 72 end
tree_report()
click to toggle source
the name of the callgrind profile file
# File lib/ruby-prof/printers/multi_printer.rb 65 def tree_report 66 "#{@directory}/#{@profile}.callgrind.out.#{$$}" 67 end
validate_print_params(options)
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb 119 def validate_print_params(options) 120 if options.is_a?(IO) 121 raise ArgumentError, "#{self.class.name}#print cannot print to IO objects" 122 elsif !options.is_a?(Hash) 123 raise ArgumentError, "#{self.class.name}#print requires an options hash" 124 end 125 end