class RubyProf::MultiPrinter
profile, a call stack profile and a graph profile.
one profiling run. Currently prints a flat profile, a callgrind
Helper class to simplify printing profiles of several types from
def self.needs_dir?
def self.needs_dir? true end
def call_info_report
def call_info_report "#{@directory}/#{@file_name}.call_tree.txt" end
def dot_report
def dot_report "#{@directory}/#{@file_name}.dot" end
def flat_report
def flat_report "#{@directory}/#{@file_name}.flat.txt" end
def graph_html_report
def graph_html_report "#{@directory}/#{@file_name}.graph.html" end
def graph_report
def graph_report "#{@directory}/#{@file_name}.graph.txt" end
def initialize(result, printers = [:flat, :graph_html])
def initialize(result, printers = [:flat, :graph_html]) @flat_printer = printers.include?(:flat) ? FlatPrinter.new(result) : nil @graph_printer = printers.include?(:graph) ? GraphPrinter.new(result) : nil @graph_html_printer = printers.include?(:graph_html) ? GraphHtmlPrinter.new(result) : nil @tree_printer = printers.include?(:tree) ? CallTreePrinter.new(result) : nil @call_info_printer = printers.include?(:call_tree) ? CallInfoPrinter.new(result) : nil @stack_printer = printers.include?(:stack) ? CallStackPrinter.new(result) : nil @dot_printer = printers.include?(:dot) ? DotPrinter.new(result) : nil end
def print(options)
directory. options[:profile] is used as the base name for the
create profile files under options[:path] or the current
def print(options) validate_print_params(options) @file_name = 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
def print_to_call_info(options)
def print_to_call_info(options) File.open(call_info_report, "wb") do |file| @call_info_printer.print(file, options) end end
def print_to_dot(options)
def print_to_dot(options) File.open(dot_report, "wb") do |file| @dot_printer.print(file, options) end end
def print_to_flat(options)
def print_to_flat(options) File.open(flat_report, "wb") do |file| @flat_printer.print(file, options) end end
def print_to_graph(options)
def print_to_graph(options) File.open(graph_report, "wb") do |file| @graph_printer.print(file, options) end end
def print_to_graph_html(options)
def print_to_graph_html(options) File.open(graph_html_report, "wb") do |file| @graph_html_printer.print(file, options) end end
def print_to_stack(options)
def print_to_stack(options) File.open(stack_report, "wb") do |file| @stack_printer.print(file, options.merge(:graph => "#{@file_name}.graph.html")) end end
def print_to_tree(options)
def print_to_tree(options) @tree_printer.print(options.merge(:path => @directory, :profile => @file_name)) end
def stack_report
def stack_report "#{@directory}/#{@file_name}.stack.html" end
def tree_report
def tree_report "#{@directory}/#{@file_name}.callgrind.out.#{$$}" end
def validate_print_params(options)
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