forked from eliotsykes/rails-testing-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstackprof.rb
31 lines (27 loc) · 1.04 KB
/
stackprof.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# In your ./Gemfile:
gem 'stackprof', group: :test
# At top of ./spec/rails_helper.rb
if ENV['STACKPROF']
require 'stackprof'
StackProf.start(mode: :wall, raw: true, interval: 1000, out: 'tmp/stackprof-wall-test.dump')
at_exit do
StackProf.stop
StackProf.results
end
end
# Depending on size of test suite, the above may produce too much output, consider
# running it only on selected specs by passing the spec paths to `rspec`:
# Profile checkout feature specs only:
# STACKPROF=1 bin/rspec spec/features/checkout
# To view results table:
# bundle exec stackprof tmp/stackprof-wall-test.dump
#
# To view flamegraph:
# 1) Generate data
# bundle exec stackprof --flamegraph tmp/stackprof-wall-test.dump > tmp/flamegraph
# 2) Open flamegraph in browser
# - NOTE: when Safari is used this may not copy over the querystring correctly
# so check the URL generated by the below command and copy it manually
# to your browser.
# - May be slow to generate graph
# bundle exec stackprof --flamegraph-viewer=tmp/flamegraph