require 'ruby-prof'
require 'ruby-prof-flamegraph'
result = RubyProf.profile do
# code to profile
end
printer = printer = RubyProf::FlameGraphPrinter.new(result)
File.open("tmp/flamegraph-data-#{DateTime.now.iso8601}", 'w') do |f|
printer.print(f, {})
end
gem 'ruby-prof'
gem 'ruby-prof-flamegraph'
cat $(ls -1tr tmp/flamegraph-* | tail -n1) | ~/src/FlameGraph/flamegraph.pl --countname=ms --width=728 | bcat
For use in Rack apps.
require 'rack-mini-profiler'
require 'flamegraph'
use Rack::MiniProfiler
gem 'rack-mini-profiler'
gem 'flamegraph'