Skip to content

Instantly share code, notes, and snippets.

@soberstadt
Last active September 24, 2025 01:42
Show Gist options
  • Select an option

  • Save soberstadt/8b366555a9d7057b8808803f0c5e8032 to your computer and use it in GitHub Desktop.

Select an option

Save soberstadt/8b366555a9d7057b8808803f0c5e8032 to your computer and use it in GitHub Desktop.
Rails boot profiling
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'stackprof'
end
profile = StackProf.run(raw: true) do
require_relative "config/environment"
ActiveRecord::Base.connection.verify!
end
File.write('tmp/stackprof.json', JSON.generate(profile))
# open tmp/stackprof.json in https://www.speedscope.app/
@soberstadt
Copy link
Author

Save this file in the root of your rails app. Run it with ruby boot_profile.rb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment