Skip to content

Instantly share code, notes, and snippets.

@tizoc
Created February 20, 2012 21:02
Show Gist options
  • Save tizoc/1871395 to your computer and use it in GitHub Desktop.
Save tizoc/1871395 to your computer and use it in GitHub Desktop.
# ... app code ....
require 'ruby-prof'
run(lambda do |env|
case env['PATH_INFO']
when '/__START__' then
RubyProf.start
Rack::Response.new("Start profile").finish
when '/__STOP__' then
out = StringIO.new
RubyProf::DotPrinter.new(RubyProf.stop).print(out, min_percent: 2)
out.close
Rack::Response.new(out.string).finish
else
$app.call(env)
# Cuba.call(env)
end
end)
# $ curl http://127.0.0.1:8080/__START__; ab -n 1000 -c 10 http://127.0.0.1:8080/home; curl http://127.0.0.1:8080/__START__ > g.dot; dot -Tpng g.dot > g.png; open g.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment