It's something similar to flamegraph but without an image (yet? feel free to pull request). For example, add this to your program:
if ENV["MY_TRACEREPLAY_FLAG"]
require "tracereplay"
TraceReplay.start File.new("temp.htm", "w"),
"/Users/nakilon/.rbenv/versions/2.7.8/lib/ruby/gems/2.7.0/gems/",
"/Users/nakilon/.rbenv/versions/2.7.8/lib/ruby/gems/2.7.0/bundler/gems/",
"/Users/nakilon/.rbenv/versions/2.7.8/lib/ruby/2.7.0/",
"/Users/nakilon/my_repo/"
endand run it like this:
$ MY_TRACEREPLAY_FLAG=_ bundle exec rspec test.rb:463The program will run several times slower because it's tracing, and in the end there will be a local file ./temp.htm, that you open in browser and move the mouse around to see traces with call counts, smth like this:
In this specific usage example we may decide to reduce the number of #random_example calls to the third-party gem we use in line ./document.rb:265. It may also give a hint that there is some mistake in your algorithm, or explain that big chunk of time (the width of the page that you hover with your mouse) is some slow pre- or post- execution step.