ruby profiling with ruby-prof

Developer from somewhere

Useful snippet to profile a piece of code:

RubyProf.start

results = RubyProf.stop

File.open "./#{Time.now.strftime("%H-%M-%S")}_res.html", 'w' do |file|
  RubyProf::GraphHtmlPrinter.new(results).print(file)
end

After this, you’ll have a timestamped file containing benchmark results. Really useful for optimization.