Pry-Stackprofiler
Please read the stackprofiler
gem README for background on Stackprofiler
in general.
This is a Pry plugin that makes benchmarking of code using Stackprofiler a much more fluid experience and provide a quicker turn-around time. It does this by passing along Pry's linebuffer to the Stackprofiler server so that code needn't be stored in the file system for Stackprofiler to annotate.
Installation
$ gem install pry-stackprofiler
Once installed, Pry should autoload the plugin. No require
necessary. There is
some setup required on the plugin side; specifically, the plugin needs to be told
where to send profile data. This can be done either by means of an environment
variable or in ~/.pryrc
.
# ~/.pryrc
Pry.config.pry_stackprofiler_ui_url = "http://localhost:9260/receive"
or
# ~/.bashrc
export PRY_STACKPROFILER_UI_URL=http://localhost:9260/receive
Usage
Start up Stackprofiler on the command line:
$ stackprofiler
In another tab, start up a Pry session:
$ pry
[1] pry(main)> Pry.profile do
[1] pry(main)* sleep 0.3
[1] pry(main)* sleep 0.4
[1] pry(main)* sleep 0.1
[1] pry(main)* end
Now navigate to Stackprofiler (probably at http://localhost:9260/) and see which lines were slowest!
You can pass an options hash to Pry::profile
if desired. The most useful key is interval
and specifies how often the code should be sampled in microseconds. The default is 1000.
Contributing
- Fork it ( https://github.com/glassechidna/pry-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