Importing from stackprof (ruby)

Jamie Wong edited this page Aug 21, 2018 · 1 revision

stackprof is a sampling call-stack profiler for Ruby.

To record a profile, wrap your code in a StackProf.run block with raw: true, then save the JSON encoded version of the profile to a file.

require 'json'
require 'stackprof'

profile = StackProf.run(mode: :wall, raw: true) do
  # Do your thing here
end

File.write('stackprof.json', JSON.generate(profile))

Then drop the resulting stackprof.json into https://www.speedscope.app/

To view it offline, you'll need to install speedscope via npm:

npm install -g speedscope

Then you should be able to open it like so:

speedscope stackprof.json
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.