Created
August 15, 2018 05:50
-
-
Save hkdnet/3a6cea0543a7fc89f2f4129ffacd59b4 to your computer and use it in GitHub Desktop.
rack middleware ごとの経過時間をはかるやつ
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
# ref: http://blog.mirakui.com/entry/2012/04/03/slow-middleware | |
module RackMiddlewareBenchmarker | |
module Benchmarker | |
def call(env) | |
result = nil | |
ms = Benchmark.ms { result = super } | |
puts "MIDDLEWARE END #{self.class.to_s} (#{ms.to_i}ms)" | |
result | |
end | |
end | |
def build(app) | |
app.class.prepend(Benchmarker) | |
super | |
end | |
end | |
ActionDispatch::MiddlewareStack::Middleware.prepend(RackMiddlewareBenchmarker) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment