Skip to content

Instantly share code, notes, and snippets.

@bmarini
Created June 14, 2011 18:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmarini/1025483 to your computer and use it in GitHub Desktop.
Save bmarini/1025483 to your computer and use it in GitHub Desktop.
ruby-prof scaffold code
require 'ruby-prof'
# RubyProf.measure_mode = RubyProf::PROCESS_TIME
# RubyProf.measure_mode = RubyProf::WALL_TIME
# RubyProf.measure_mode = RubyProf::CPU_TIME
# RubyProf.measure_mode = RubyProf::ALLOCATIONS
# RubyProf.measure_mode = RubyProf::MEMORY
# RubyProf.measure_mode = RubyProf::GC_RUNS
# RubyProf.measure_mode = RubyProf::GC_TIME
result = RubyProf.profile do
# Do stuff in here
end
# Print a graph profile to text
printer = RubyProf::GraphHtmlPrinter.new(result)
File.open(Rails.root.join("tmp/performance/profile_blah.html"), "w") do |file|
printer.print(file, {:min_percent => 10})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment