Skip to content

Importing from ruby prof

Jamie Wong edited this page Apr 28, 2020 · 1 revision

ruby-prof is a tracing ruby profiler that lets you profile specific parts of the code that you choose.

The gem ruby-prof-speedscope (https://github.com/chanzuckerberg/ruby-prof-speedscope) provides a "Printer" that outputs ruby-prof profiles in the speedscope format.

To record and save a profile with ruby-prof, do something like the following:

# Collect the profile
results = RubyProf.profile do
  # ... some slow stuff
end

# Save the results
File.open("/tmp/profile.speedscope.json") do |f|
  RubyProf::SpeedscopePrinter.new(results).print(f)
end

Then drop the resulting profile.speedscope.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 /tmp/profile.speedscope.json