Module: TestProf::RubyProf
- Extended by:
- Logging
- Defined in:
- lib/test_prof/ruby_prof.rb
Overview
RubyProf wrapper.
Has 2 modes: global and per-example.
Example:
# To activate global profiling you can use env variable
TEST_RUBY_PROF=1 rspec ...
# or in your code
TestProf::RubyProf.run
To profile a specific examples add :rprof tag to it:
it "is doing heavy stuff", :rprof do
...
end
Defined Under Namespace
Classes: Configuration, Report
Constant Summary
Constants included from Logging
Class Method Summary collapse
- .config ⇒ Object
- .configure {|config| ... } ⇒ Object
- .profile ⇒ Object
-
.run ⇒ Object
Run RubyProf and automatically dump a report when the process exits.
Methods included from Logging
Class Method Details
.config ⇒ Object
137 138 139 |
# File 'lib/test_prof/ruby_prof.rb', line 137 def config @config ||= Configuration.new end |
.configure {|config| ... } ⇒ Object
141 142 143 |
# File 'lib/test_prof/ruby_prof.rb', line 141 def configure yield config end |
.profile ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/test_prof/ruby_prof.rb', line 161 def profile return if locked? return unless init_ruby_prof = { merge_fibers: true } [:include_threads] = [Thread.current] unless config.include_threads? profiler = ::RubyProf::Profile.new() profiler.start Report.new(profiler) end |
.run ⇒ Object
Run RubyProf and automatically dump a report when the process exits.
Use this method to profile the whole run.
149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/test_prof/ruby_prof.rb', line 149 def run report = profile return unless report @locked = true log :info, "RubyProf enabled" at_exit { report.dump("total") } end |