- Existing
rspec-stackprofis "empty" stackprofis written as a replacement forperftools.rb- Added an environment variable to conditionally run the profiler, it slows down test runtime by a couple of seconds for me.
- Just add
stackprof.rbto yourspec/supportfolder, which is loaded onrails_helper.rb
Created
November 17, 2014 21:39
-
-
Save leonelgalan/a613c1d8e293f3219327 to your computer and use it in GitHub Desktop.
Using stackprof and rspec (Rails)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if ENV['STACKPROF'] | |
| require 'stackprof' | |
| RSpec.configure do |config| | |
| config.before :suite do | |
| StackProf.start(mode: :cpu, interval: 1000, out: 'tmp/stackprof-cpu-myapp.dump') | |
| end | |
| config.after :suite do | |
| StackProf.stop | |
| StackProf.results | |
| end | |
| end | |
| end | |
| # STACKPROF=TRUE rspec | |
| # stackprof tmp/stackprof-cpu-*.dump --text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
StackProf.start(mode: ENV['STACKPROF'].to_sym, interval: 1000, out: "tmp/stackprof-#{ENV['STACKPROF']}-myapp.dump")is way more useful, this way you can doSTACKPROF=cpuor any other mode