Stackprofiler is a web UI wrapper for the excellent
sampling call-stack profiler for Ruby 2.1+.
stackprof features a
command-line tool that is very handy for inspecting hotspots in code,
but seeing the "bigger picture" can be difficult without a GUI to
click around in. Hence: Stackprofiler.
There already exist gems in this vein. Most (all?) are based on
rubyprof, an instrumenting profiler for Ruby 1.9.3+.
Unfortunately, in my experience RubyProf has an unacceptably
high overhead when profiling already-slow code and this makes
profiling very frustrating, if not useless. Maybe I'm holding it
stackprof seems much more useful.
Stackprofiler is in an incredibly early state of development. The only reason it has been published this early is as supporting evidence for a job application! Please keep that in mind when you find all the rough edges :)
$ gem install stackprofiler
Stackprofiler is a stand-alone Ruby app that can be installed using Rubygems. The client gems (see below) should probably be installed as part of a Bundler Gemfile.
Once installed, the Stackprofiler web UI can be started from the terminal by
stackprofiler. By itself, it won't do much. It will wait for profile
data to come in from client gems. There are a handful of these gems and they
are listed below.
Stackprofiler can be used to measure the performance of Ruby-powered websites
by using a drop-in Rack middleware. This middleware is provided by a separate
The reason for a separate gem is so that Stackprofiler can be used in as many circumstances as possible. Your app may have dependencies that conflict with those powering the Stackprofiler web UI and it would be a shame to miss out on using this tool on account of that.
Head on over to the README for that gem to learn how to use it.
Sometimes you want to test some code that isn't part of a Rack app - or is
just cumbersome to run outside of an IRB console. You can test this code
directly very easily using the
pry-stackprofiler gem in the Pry
Pry is an alternative to IRB with handy support for plugins.
is such a plugin and works well with the Stackprofiler server. Once installed,
you can type code into the REPL like:
Pry.profile do sleep 0.3 sleep 0.4 sleep 0.1 end
And the profile results will appear in the Stackprofiler web UI. For running instructions, refer to the gem's README.
Stackprofiler can also be used to measure the performance of background jobs
powered by Sidekiq. It does this using the
gem. Have a look at the README for that gem to learn more.
- Fork it ( https://github.com/glassechidna/stackprofiler/fork )
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create a new Pull Request
So much. First todo: write a todo list.