Class: TestProf::RubyProf::Configuration
- Inherits:
-
Object
- Object
- TestProf::RubyProf::Configuration
- Defined in:
- lib/test_prof/ruby_prof.rb
Overview
RubyProf configuration
Constant Summary collapse
- PRINTERS =
{ "flat" => "FlatPrinter", "flat_wln" => "FlatPrinterWithLineNumbers", "graph" => "GraphPrinter", "graph_html" => "GraphHtmlPrinter", "dot" => "DotPrinter", "." => "DotPrinter", "call_stack" => "CallStackPrinter", "call_tree" => "CallTreePrinter", "multi" => "MultiPrinter" }.freeze
- PRINTER_EXTENSTION =
Mapping from printer to report file extension NOTE: txt is not included and considered default
{ "graph_html" => "html", "dot" => "dot", "." => "dot", "call_stack" => "html" }.freeze
- LOGFILE_PREFIX =
"ruby-prof-report"
Instance Attribute Summary collapse
-
#custom_exclusions ⇒ Object
Returns the value of attribute custom_exclusions.
-
#exclude_common_methods ⇒ Object
Returns the value of attribute exclude_common_methods.
-
#include_threads ⇒ Object
Returns the value of attribute include_threads.
-
#min_percent ⇒ Object
Returns the value of attribute min_percent.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#printer ⇒ Object
Returns the value of attribute printer.
-
#skip_boot ⇒ Object
Returns the value of attribute skip_boot.
-
#test_prof_exclusions_enabled ⇒ Object
Returns the value of attribute test_prof_exclusions_enabled.
Instance Method Summary collapse
- #exclude_common_methods? ⇒ Boolean
- #include_threads? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#resolve_printer ⇒ Object
Returns an array of printer type (ID) and class.
- #ruby_prof_mode ⇒ Object
- #skip_boot? ⇒ Boolean
- #test_prof_exclusions_enabled? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/test_prof/ruby_prof.rb', line 53 def initialize @printer = ENV["TEST_RUBY_PROF"].to_sym if PRINTERS.key?(ENV["TEST_RUBY_PROF"]) @printer ||= ENV.fetch("TEST_RUBY_PROF_PRINTER", :flat).to_sym @mode = ENV.fetch("TEST_RUBY_PROF_MODE", :wall).to_s @skip_boot = %w[0 false f].include?(ENV["TEST_RUBY_PROF_BOOT"]) @min_percent = 1 @include_threads = false @exclude_common_methods = true @test_prof_exclusions_enabled = true @custom_exclusions = {} end |
Instance Attribute Details
#custom_exclusions ⇒ Object
Returns the value of attribute custom_exclusions.
48 49 50 |
# File 'lib/test_prof/ruby_prof.rb', line 48 def custom_exclusions @custom_exclusions end |
#exclude_common_methods ⇒ Object
Returns the value of attribute exclude_common_methods.
48 49 50 |
# File 'lib/test_prof/ruby_prof.rb', line 48 def exclude_common_methods @exclude_common_methods end |
#include_threads ⇒ Object
Returns the value of attribute include_threads.
48 49 50 |
# File 'lib/test_prof/ruby_prof.rb', line 48 def include_threads @include_threads end |
#min_percent ⇒ Object
Returns the value of attribute min_percent.
48 49 50 |
# File 'lib/test_prof/ruby_prof.rb', line 48 def min_percent @min_percent end |
#mode ⇒ Object
Returns the value of attribute mode.
48 49 50 |
# File 'lib/test_prof/ruby_prof.rb', line 48 def mode @mode end |
#printer ⇒ Object
Returns the value of attribute printer.
48 49 50 |
# File 'lib/test_prof/ruby_prof.rb', line 48 def printer @printer end |
#skip_boot ⇒ Object
Returns the value of attribute skip_boot.
48 49 50 |
# File 'lib/test_prof/ruby_prof.rb', line 48 def skip_boot @skip_boot end |
#test_prof_exclusions_enabled ⇒ Object
Returns the value of attribute test_prof_exclusions_enabled.
48 49 50 |
# File 'lib/test_prof/ruby_prof.rb', line 48 def test_prof_exclusions_enabled @test_prof_exclusions_enabled end |
Instance Method Details
#exclude_common_methods? ⇒ Boolean
73 74 75 |
# File 'lib/test_prof/ruby_prof.rb', line 73 def exclude_common_methods? exclude_common_methods == true end |
#include_threads? ⇒ Boolean
65 66 67 |
# File 'lib/test_prof/ruby_prof.rb', line 65 def include_threads? include_threads == true end |
#resolve_printer ⇒ Object
Returns an array of printer type (ID) and class.
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/test_prof/ruby_prof.rb', line 82 def resolve_printer return ["custom", printer] if printer.is_a?(Module) type = printer.to_s raise ArgumentError, "Unknown printer: #{type}" unless PRINTERS.key?(type) [type, ::RubyProf.const_get(PRINTERS[type])] end |
#ruby_prof_mode ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/test_prof/ruby_prof.rb', line 94 def ruby_prof_mode case mode when "wall", "wall_time" ::RubyProf::WALL_TIME when "allocations" ::RubyProf::ALLOCATIONS when "memory" ::RubyProf::MEMORY when "process", "process_time" ::RubyProf::PROCESS_TIME else ::RubyProf::WALL_TIME end end |
#skip_boot? ⇒ Boolean
69 70 71 |
# File 'lib/test_prof/ruby_prof.rb', line 69 def skip_boot? skip_boot == true end |
#test_prof_exclusions_enabled? ⇒ Boolean
77 78 79 |
# File 'lib/test_prof/ruby_prof.rb', line 77 def test_prof_exclusions_enabled? @test_prof_exclusions_enabled == true end |