gitlab-org--gitlab-foss/bin/rspec-stackprof

17 lines
549 B
Ruby
Executable file

#!/usr/bin/env ruby
require_relative '../config/bundler_setup'
require 'stackprof'
require 'rspec'
filename = ARGV[0].split('/').last
interval = ENV.fetch('INTERVAL', 1000).to_i
limit = ENV.fetch('LIMIT', 20)
raw = ENV.fetch('RAW', false) == 'true' # Set this to true if you want to generate a flamegraph
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}")