Skip to content

Instantly share code, notes, and snippets.

@yorickpeterse
Created October 13, 2014 20:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yorickpeterse/1724eb9184e27a23e6df to your computer and use it in GitHub Desktop.
Save yorickpeterse/1724eb9184e27a23e6df to your computer and use it in GitHub Desktop.
require 'rack'
require 'rubinius/profiler'
class RbxRackProfiler
def initialize(app)
@app = app
end
def call(env)
profiler = Rubinius::Profiler::Instrumenter.new
profiler.start
retval = @app.call(env)
profiler.stop
puts
puts "=== #{env['REQUEST_METHOD']} #{env['PATH_INFO'].inspect} ==="
puts
profiler.show
return retval
end
end
class MyApp
def call(env)
return [200, {'Content-Type' => 'text/plain'}, ['Hello world!']]
end
end
use RbxRackProfiler
run MyApp.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment