Skip to content

Instantly share code, notes, and snippets.

@catatsuy
Created March 10, 2015 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catatsuy/35eeb2ddfd7a2a548251 to your computer and use it in GitHub Desktop.
Save catatsuy/35eeb2ddfd7a2a548251 to your computer and use it in GitHub Desktop.
require 'ruby-prof'
RubyProf.start
# code...
results = RubyProf.stop
# Print a flat profile to text
File.open "#{Rails.root}/tmp/performance/#{file_name}-graph.html", 'w' do |file|
RubyProf::GraphHtmlPrinter.new(results).print(file)
end
File.open "#{Rails.root}/tmp/performance/#{file_name}-flat.txt", 'w' do |file|
# RubyProf::FlatPrinter.new(results).print(file)
RubyProf::FlatPrinterWithLineNumbers.new(results).print(file)
end
File.open "#{Rails.root}/tmp/performance/#{file_name}-stack.html", 'w' do |file|
RubyProf::CallStackPrinter.new(results).print(file)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment