summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2016-11-04 11:43:02 +0000
committerNick Thomas <nick@gitlab.com>2016-11-29 14:14:34 +0000
commit5e05f9c5c2cfaf14cc0337c23ff54f86c5d5f5a8 (patch)
tree5e7bd4ddeb096317fe8423bda2cda138939eb961 /bin
parente6d31ce31ff9d408503ea7b0ba1e6faad7cd5290 (diff)
downloadgitlab-ce-5e05f9c5c2cfaf14cc0337c23ff54f86c5d5f5a8.tar.gz
Add StackProf to the Gemfile, along with a utility to get a profile for a spec
Diffstat (limited to 'bin')
-rwxr-xr-xbin/rspec-stackprof16
1 files changed, 16 insertions, 0 deletions
diff --git a/bin/rspec-stackprof b/bin/rspec-stackprof
new file mode 100755
index 00000000000..df79feb201d
--- /dev/null
+++ b/bin/rspec-stackprof
@@ -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}")