How to use test_prof_exclusions_enabled method of RubyProf Package

Best Test-prof_ruby code snippet using RubyProf.test_prof_exclusions_enabled


Source:ruby_prof.rb Github


Full Screen

...42 }.freeze43 LOGFILE_PREFIX = "ruby-prof-report"44 attr_accessor :printer, :mode, :min_percent,45 :include_threads, :exclude_common_methods,46 :test_prof_exclusions_enabled,47 :custom_exclusions48 def initialize49 @printer = ENV["TEST_RUBY_PROF"].to_sym if PRINTERS.key?(ENV["TEST_RUBY_PROF"])50 @printer ||= ENV.fetch("TEST_RUBY_PROF_PRINTER", :flat).to_sym51 @mode = ENV.fetch("TEST_RUBY_PROF_MODE", :wall).to_sym52 @min_percent = 153 @include_threads = false54 @exclude_common_methods = true55 @test_prof_exclusions_enabled = true56 @custom_exclusions = {}57 end58 def include_threads?59 include_threads == true60 end61 def exclude_common_methods?62 exclude_common_methods == true63 end64 def test_prof_exclusions_enabled?65 @test_prof_exclusions_enabled == true66 end67 # Returns an array of printer type (ID) and class.68 def resolve_printer69 return ["custom", printer] if printer.is_a?(Module)70 type = printer.to_s71 raise ArgumentError, "Unknown printer: #{type}" unless72 PRINTERS.key?(type)73 [type, ::RubyProf.const_get(PRINTERS[type])]74 end75 end76 # Wrapper over RubyProf profiler and printer77 class Report78 include TestProf::Logging79 def initialize(profiler)80 @profiler = profiler81 end82 # Stop profiling and generate the report83 # using provided name.84 def dump(name)85 result = @profiler.stop86 printer_type, printer_class = config.resolve_printer87 if %w[call_tree multi].include?(printer_type)88 path = TestProf.create_artifact_dir89 path: path,91 profile: "#{RubyProf::Configuration::LOGFILE_PREFIX}-#{printer_type}-" \92 "#{config.mode}-#{name}",93 min_percent: config.min_percent94 )95 else96 path = build_path name, printer_type97, "w") do |f|98, min_percent: config.min_percent)99 end100 end101 log :info, "RubyProf report generated: #{path}"102 end103 private104 def build_path(name, printer)105 TestProf.artifact_path(106 "#{RubyProf::Configuration::LOGFILE_PREFIX}-#{printer}-#{config.mode}-#{name}" \107 ".#{RubyProf::Configuration::PRINTER_EXTENSTION.fetch(printer, "txt")}"108 )109 end110 def config111 RubyProf.config112 end113 end114 class << self115 include Logging116 def config117 @config ||= Configuration.new118 end119 def configure120 yield config121 end122 # Run RubyProf and automatically dump123 # a report when the process exits.124 #125 # Use this method to profile the whole run.126 def run127 report = profile128 return unless report129 @locked = true130 log :info, "RubyProf enabled globally"131 at_exit { report.dump("total") }132 end133 def profile134 if locked?135 log :warn, <<~MSG136 RubyProf is activated globally, you cannot generate per-example report.137 Make sure you haven's set the TEST_RUBY_PROF environmental variable.138 MSG139 return140 end141 return unless init_ruby_prof142 options = {143 merge_fibers: true144 }145 options[:include_threads] = [Thread.current] unless146 config.include_threads?147 profiler = profiler.exclude_common_methods! if config.exclude_common_methods?149 if config.test_prof_exclusions_enabled?150 # custom test-prof exclusions151 exclude_rspec_methods(profiler)152 # custom global exclusions153 exclude_common_methods(profiler)154 end155 config.custom_exclusions.each do |klass, mids|156 profiler.exclude_methods! klass, *mids157 end158 profiler.start159 end161 private162 def locked?163 @locked == true...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Test-prof_ruby automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?