Class: Utopia::Middleware::Benchmark

Inherits:
Object
  • Object
show all
Defined in:
lib/utopia/middleware/benchmark.rb

Instance Method Summary collapse

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, options = {})
	@app = app
	@tag = options[: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