Created
October 13, 2014 20:59
-
-
Save yorickpeterse/1724eb9184e27a23e6df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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