Class: RubyProf::AbstractPrinter
- Inherits:
-
Object
- Object
- RubyProf::AbstractPrinter
- Defined in:
- lib/ruby-prof/printers/abstract_printer.rb
Direct Known Subclasses
CallInfoPrinter, CallStackPrinter, CallTreePrinter, DotPrinter, FlatPrinter, GraphHtmlPrinter, GraphPrinter
Class Method Summary collapse
-
.needs_dir? ⇒ Boolean
whether this printer need a :path option pointing to a directory.
Instance Method Summary collapse
- #editor_uri ⇒ Object
-
#initialize(result) ⇒ AbstractPrinter
constructor
Create a new printer.
- #method_name(method) ⇒ Object
- #min_percent ⇒ Object
-
#print(output = STDOUT, options = {}) ⇒ Object
Print a profiling report to the provided output.
- #print_file ⇒ Object
- #print_footer(thread) ⇒ Object
- #print_header(thread) ⇒ Object
- #print_thread(thread) ⇒ Object
- #print_threads ⇒ Object
-
#setup_options(options = {}) ⇒ Object
Specify print options.
- #sort_method ⇒ Object
Constructor Details
#initialize(result) ⇒ AbstractPrinter
Create a new printer.
result should be the output generated from a profiling run
8 9 10 11 |
# File 'lib/ruby-prof/printers/abstract_printer.rb', line 8 def initialize(result) @result = result @output = nil end |
Class Method Details
.needs_dir? ⇒ Boolean
whether this printer need a :path option pointing to a directory
99 100 101 |
# File 'lib/ruby-prof/printers/abstract_printer.rb', line 99 def self.needs_dir? false end |
Instance Method Details
#editor_uri ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/ruby-prof/printers/abstract_printer.rb', line 48 def editor_uri default_uri = if RUBY_PLATFORM =~ /darwin/ \ && !ENV['RUBY_PROF_EDITOR_URI'] 'txmt' else false end ENV['RUBY_PROF_EDITOR_URI'] || @options[:editor_uri] || default_uri end |
#method_name(method) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/ruby-prof/printers/abstract_printer.rb', line 58 def method_name(method) name = method.full_name if print_file name += " (#{method.source_file}:#{method.line}}" end name end |
#min_percent ⇒ Object
36 37 38 |
# File 'lib/ruby-prof/printers/abstract_printer.rb', line 36 def min_percent @options[:min_percent] || 0 end |
#print(output = STDOUT, options = {}) ⇒ Object
Print a profiling 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. Note that each printer can define its own set of options.
74 75 76 77 78 |
# File 'lib/ruby-prof/printers/abstract_printer.rb', line 74 def print(output = STDOUT, = {}) @output = output () print_threads end |
#print_file ⇒ Object
40 41 42 |
# File 'lib/ruby-prof/printers/abstract_printer.rb', line 40 def print_file @options[:print_file] || false end |
#print_footer(thread) ⇒ Object
95 96 |
# File 'lib/ruby-prof/printers/abstract_printer.rb', line 95 def (thread) end |
#print_header(thread) ⇒ Object
92 93 |
# File 'lib/ruby-prof/printers/abstract_printer.rb', line 92 def print_header(thread) end |
#print_thread(thread) ⇒ Object
86 87 88 89 90 |
# File 'lib/ruby-prof/printers/abstract_printer.rb', line 86 def print_thread(thread) print_header(thread) print_methods(thread) (thread) end |
#print_threads ⇒ Object
80 81 82 83 84 |
# File 'lib/ruby-prof/printers/abstract_printer.rb', line 80 def print_threads @result.threads.each do |thread| print_thread(thread) end end |
#setup_options(options = {}) ⇒ Object
Specify print options.
options - Hash table
:min_percent - Number 0 to 100 that specifes the minimum
%self (the methods self time divided by the
overall total time) that a method must take
for it to be printed out in the report.
Default value is 0.
:print_file - True or false. Specifies if a method's source
file should be printed. Default value if false.
:sort_method - Specifies method used for sorting method infos.
Available values are :total_time, :self_time,
:wait_time, :children_time
Default value is :total_time
:editor_uri - Specifies editor uri scheme used for opening files
e.g. :atm or :mvim. For OS X default is :txmt.
Use RUBY_PROF_EDITOR_URI environment variable to overide.
32 33 34 |
# File 'lib/ruby-prof/printers/abstract_printer.rb', line 32 def ( = {}) @options = end |
#sort_method ⇒ Object
44 45 46 |
# File 'lib/ruby-prof/printers/abstract_printer.rb', line 44 def sort_method @options[:sort_method] || :total_time end |