Class: Utopia::Middleware::Benchmark
- Inherits:
-
Object
- Object
- Utopia::Middleware::Benchmark
- Defined in:
- lib/utopia/middleware/benchmark.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Benchmark
constructor
A new instance of Benchmark.
Constructor Details
#initialize(app, options = {}) ⇒ Benchmark
Returns a new instance of Benchmark.
27 28 29 30 |
# File 'lib/utopia/middleware/benchmark.rb', line 27 def initialize(app, = {}) @app = app @tag = [:tag] || "{{benchmark}}" end |
Instance Method Details
#call(env) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/utopia/middleware/benchmark.rb', line 32 def call(env) start = Time.now response = @app.call(env) finish = Time.now time = "%0.4f" % (finish - start) env['rack.errors'].puts "Benchmark: Request #{env["PATH_INFO"]} took #{time}s" return response end |