summaryrefslogtreecommitdiff
path: root/bin/rspec-stackprof
blob: 3bef45c607c2e14f2f93c57bce7df525b0df9ef0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env ruby

require 'bundler/setup'
require 'stackprof'
$:.unshift 'spec'
require 'spec_helper'

filename = ARGV[0].split('/').last
interval = ENV.fetch('INTERVAL', 1000).to_i
limit = ENV.fetch('LIMIT', 20)
raw = ENV.fetch('RAW', false) == 'true'
output_file = "tmp/#{filename}.dump"

StackProf.run(mode: :wall, out: output_file, interval: interval, raw: raw) do
  RSpec::Core::Runner.run(ARGV, $stderr, $stdout)
end

system("bundle exec stackprof #{output_file} --text --limit #{limit}")