Stackprofiler

Stackprofiler is a web UI wrapper for the excellent stackprof 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 wrong, but 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 :)

Screenshot Screenshot

Installation

$ 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.

Usage

Once installed, the Stackprofiler web UI can be started from the terminal by running 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.

Other gems

Rack Middleware

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 gem; stackprofiler-middleware.

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.

Pry Plugin

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 REPL.

Pry is an alternative to IRB with handy support for plugins. pry-stackprofiler 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.

Sidekiq Middleware

Stackprofiler can also be used to measure the performance of background jobs powered by Sidekiq. It does this using the stackprofiler-sidekiq middleware gem. Have a look at the README for that gem to learn more.

Contributing

  1. Fork it ( https://github.com/glassechidna/stackprofiler/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

TODO

So much. First todo: write a todo list.