Created
November 25, 2019 09:32
-
-
Save ang3lkar/8b7fbbd387e57dc0943ddc4cd885dd33 to your computer and use it in GitHub Desktop.
Benchmark Rails middleware
This file contains hidden or 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
# Open an Rails console and paste these below. | |
# (exit and open another in case of edit) | |
noop = Proc.new {[200, {}, ["hello"]]} | |
request = Rack::MockRequest.new(noop) | |
Rails.configuration.middleware = Rails.configuration.middleware.dup | |
Benchmark.ips do |x| | |
x.config(time: 250, warmup: 5) | |
x.report("With logging middleware") { request.get("/") } | |
Rails.configuration.middleware.delete RailsSemanticLogger::Rack::Logger | |
x.report("Without logging middleware") { request.get("/") } | |
x.compare! | |
end |
Author
ang3lkar
commented
Nov 25, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment