Class: RubyProf::MultiPrinter
- Inherits:
-
Object
- Object
- RubyProf::MultiPrinter
- Defined in:
- lib/ruby-prof/printers/multi_printer.rb
Overview
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.
Class Method Summary collapse
Instance Method Summary collapse
-
#call_info_report ⇒ Object
the name of the callinfo profile file.
-
#dot_report ⇒ Object
the name of the call stack profile file.
-
#flat_report ⇒ Object
the name of the flat profile file.
- #graph_html_report ⇒ Object
-
#graph_report ⇒ Object
the name of the graph profile file.
-
#initialize(result, printers = [:flat, :graph_html]) ⇒ MultiPrinter
constructor
A new instance of MultiPrinter.
-
#print(options) ⇒ Object
create profile files under options or the current directory.
- #print_to_call_info(options) ⇒ Object
- #print_to_dot(options) ⇒ Object
- #print_to_flat(options) ⇒ Object
- #print_to_graph(options) ⇒ Object
- #print_to_graph_html(options) ⇒ Object
- #print_to_stack(options) ⇒ Object
- #print_to_tree(options) ⇒ Object
-
#stack_report ⇒ Object
the name of the call stack profile file.
-
#tree_report ⇒ Object
the name of the callgrind profile file.
- #validate_print_params(options) ⇒ Object
Constructor Details
#initialize(result, printers = [:flat, :graph_html]) ⇒ MultiPrinter
Returns a new instance of MultiPrinter.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ruby-prof/printers/multi_printer.rb', line 8 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 |
Class Method Details
.needs_dir? ⇒ Boolean
21 22 23 |
# File 'lib/ruby-prof/printers/multi_printer.rb', line 21 def self.needs_dir? true end |
Instance Method Details
#call_info_report ⇒ Object
the name of the callinfo profile file
60 61 62 |
# File 'lib/ruby-prof/printers/multi_printer.rb', line 60 def call_info_report "#{@directory}/#{@file_name}.call_tree.txt" end |
#dot_report ⇒ Object
the name of the call stack profile file
75 76 77 |
# File 'lib/ruby-prof/printers/multi_printer.rb', line 75 def dot_report "#{@directory}/#{@file_name}.dot" end |
#flat_report ⇒ Object
the name of the flat profile file
46 47 48 |
# File 'lib/ruby-prof/printers/multi_printer.rb', line 46 def flat_report "#{@directory}/#{@file_name}.flat.txt" end |
#graph_html_report ⇒ Object
55 56 57 |
# File 'lib/ruby-prof/printers/multi_printer.rb', line 55 def graph_html_report "#{@directory}/#{@file_name}.graph.html" end |
#graph_report ⇒ Object
the name of the graph profile file
51 52 53 |
# File 'lib/ruby-prof/printers/multi_printer.rb', line 51 def graph_report "#{@directory}/#{@file_name}.graph.txt" end |
#print(options) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ruby-prof/printers/multi_printer.rb', line 28 def print() validate_print_params() @file_name = .delete(:profile) || "profile" @directory = .delete(:path) || File.(".") print_to_flat() if @flat_printer print_to_graph() if @graph_printer print_to_graph_html() if @graph_html_printer print_to_stack() if @stack_printer print_to_call_info() if @call_info_printer print_to_tree() if @tree_printer print_to_dot() if @dot_printer end |
#print_to_call_info(options) ⇒ Object
97 98 99 100 101 |
# File 'lib/ruby-prof/printers/multi_printer.rb', line 97 def print_to_call_info() File.open(call_info_report, "wb") do |file| @call_info_printer.print(file, ) end end |
#print_to_dot(options) ⇒ Object
113 114 115 116 117 |
# File 'lib/ruby-prof/printers/multi_printer.rb', line 113 def print_to_dot() File.open(dot_report, "wb") do |file| @dot_printer.print(file, ) end end |
#print_to_flat(options) ⇒ Object
79 80 81 82 83 |
# File 'lib/ruby-prof/printers/multi_printer.rb', line 79 def print_to_flat() File.open(flat_report, "wb") do |file| @flat_printer.print(file, ) end end |
#print_to_graph(options) ⇒ Object
85 86 87 88 89 |
# File 'lib/ruby-prof/printers/multi_printer.rb', line 85 def print_to_graph() File.open(graph_report, "wb") do |file| @graph_printer.print(file, ) end end |
#print_to_graph_html(options) ⇒ Object
91 92 93 94 95 |
# File 'lib/ruby-prof/printers/multi_printer.rb', line 91 def print_to_graph_html() File.open(graph_html_report, "wb") do |file| @graph_html_printer.print(file, ) end end |
#print_to_stack(options) ⇒ Object
107 108 109 110 111 |
# File 'lib/ruby-prof/printers/multi_printer.rb', line 107 def print_to_stack() File.open(stack_report, "wb") do |file| @stack_printer.print(file, .merge(:graph => "#{@file_name}.graph.html")) end end |
#print_to_tree(options) ⇒ Object
103 104 105 |
# File 'lib/ruby-prof/printers/multi_printer.rb', line 103 def print_to_tree() @tree_printer.print(.merge(:path => @directory, :profile => @file_name)) end |
#stack_report ⇒ Object
the name of the call stack profile file
70 71 72 |
# File 'lib/ruby-prof/printers/multi_printer.rb', line 70 def stack_report "#{@directory}/#{@file_name}.stack.html" end |
#tree_report ⇒ Object
the name of the callgrind profile file
65 66 67 |
# File 'lib/ruby-prof/printers/multi_printer.rb', line 65 def tree_report "#{@directory}/#{@file_name}.callgrind.out.#{$$}" end |
#validate_print_params(options) ⇒ Object
119 120 121 122 123 124 125 |
# File 'lib/ruby-prof/printers/multi_printer.rb', line 119 def validate_print_params() if .is_a?(IO) raise ArgumentError, "#{self.class.name}#print cannot print to IO objects" elsif !.is_a?(Hash) raise ArgumentError, "#{self.class.name}#print requires an options hash" end end |