Add StackProf to the Gemfile, along with a utility to get a profile for a spec

This commit is contained in:
Nick Thomas
2016-11-04 11:43:02 +00:00
parent e6d31ce31f
commit 5e05f9c5c2
4 changed files with 130 additions and 0 deletions

16
bin/rspec-stackprof Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env ruby
require 'stackprof'
$:.unshift 'spec'
require 'rails_helper'
filename = ARGV[0].split('/').last
interval = ENV.fetch('INTERVAL', 1000).to_i
limit = ENV.fetch('LIMIT', 20)
output_file = "tmp/#{filename}.dump"
StackProf.run(mode: :wall, out: output_file, interval: interval) do
RSpec::Core::Runner.run(ARGV, $stderr, $stdout)
end
system("stackprof #{output_file} --text --limit #{limit}")