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, line 21 def self.needs_dir? true end
new(result, printers = [:flat, :graph_html])
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb, line 8 def initialize(result, printers = [:flat, :graph_html]) @flat_printer = FlatPrinter.new(result) if printers.include?(:flat) @graph_printer = GraphPrinter.new(result) if printers.include?(:graph) @graph_html_printer = GraphHtmlPrinter.new(result) if printers.include?(:graph_html) @tree_printer = CallTreePrinter.new(result) if printers.include?(:tree) @call_info_printer = CallInfoPrinter.new(result) if printers.include?(:call_tree) @stack_printer = CallStackPrinter.new(result) if printers.include?(:stack) @dot_printer = DotPrinter.new(result) if printers.include?(:dot) 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, line 60 def call_info_report "#{@directory}/#{@profile}.call_tree.txt" end
dot_report()
click to toggle source
the name of the call stack profile file
# File lib/ruby-prof/printers/multi_printer.rb, line 75 def dot_report "#{@directory}/#{@profile}.dot" end
flat_report()
click to toggle source
the name of the flat profile file
# File lib/ruby-prof/printers/multi_printer.rb, line 46 def flat_report "#{@directory}/#{@profile}.flat.txt" end
graph_html_report()
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb, line 55 def graph_html_report "#{@directory}/#{@profile}.graph.html" end
graph_report()
click to toggle source
the name of the graph profile file
# File lib/ruby-prof/printers/multi_printer.rb, line 51 def graph_report "#{@directory}/#{@profile}.graph.txt" 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, line 28 def print(options) validate_print_params(options) @profile = options.delete(:profile) || "profile" @directory = options.delete(:path) || File.expand_path(".") print_to_flat(options) if @flat_printer print_to_graph(options) if @graph_printer print_to_graph_html(options) if @graph_html_printer print_to_stack(options) if @stack_printer print_to_call_info(options) if @call_info_printer print_to_tree(options) if @tree_printer print_to_dot(options) if @dot_printer end
print_to_call_info(options)
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb, line 97 def print_to_call_info(options) File.open(call_info_report, "wb") do |file| @call_info_printer.print(file, options) end end
print_to_dot(options)
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb, line 113 def print_to_dot(options) File.open(dot_report, "wb") do |file| @dot_printer.print(file, options) end end
print_to_flat(options)
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb, line 79 def print_to_flat(options) File.open(flat_report, "wb") do |file| @flat_printer.print(file, options) end end
print_to_graph(options)
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb, line 85 def print_to_graph(options) File.open(graph_report, "wb") do |file| @graph_printer.print(file, options) end end
print_to_graph_html(options)
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb, line 91 def print_to_graph_html(options) File.open(graph_html_report, "wb") do |file| @graph_html_printer.print(file, options) end end
print_to_stack(options)
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb, line 107 def print_to_stack(options) File.open(stack_report, "wb") do |file| @stack_printer.print(file, options.merge(:graph => "#{@profile}.graph.html")) end end
print_to_tree(options)
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb, line 103 def print_to_tree(options) @tree_printer.print(options.merge(:path => @directory, :profile => @profile)) end
stack_report()
click to toggle source
the name of the call stack profile file
# File lib/ruby-prof/printers/multi_printer.rb, line 70 def stack_report "#{@directory}/#{@profile}.stack.html" end
tree_report()
click to toggle source
the name of the callgrind profile file
# File lib/ruby-prof/printers/multi_printer.rb, line 65 def tree_report "#{@directory}/#{@profile}.callgrind.out.#{$$}" end
validate_print_params(options)
click to toggle source
# File lib/ruby-prof/printers/multi_printer.rb, line 119 def validate_print_params(options) if options.is_a?(IO) raise ArgumentError, "#{self.class.name}#print cannot print to IO objects" elsif !options.is_a?(Hash) raise ArgumentError, "#{self.class.name}#print requires an options hash" end end