Sha256: 07fc933d2eee706b17f02bd0c35dccb5fcdb8d835512fa1b661e987f6b8fa194

Contents?: true

Size: 636 Bytes

Versions: 4

Compression:

Stored size: 636 Bytes

Contents

#	This file is part of the "Utopia Framework" project, and is released under the MIT license.
#	Copyright 2010 Samuel Williams. All rights reserved.
#	See <utopia.rb> for licensing details.

require 'utopia/middleware'

module Utopia
	module Middleware

		class Benchmark
			def initialize(app, options = {})
				@app = app
				@tag = options[:tag] || "{{benchmark}}"
			end

			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
		end

	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
utopia-0.10.0 lib/utopia/middleware/benchmark.rb
utopia-0.9.61 lib/utopia/middleware/benchmark.rb
utopia-0.9.60 lib/utopia/middleware/benchmark.rb
utopia-0.9.59 lib/utopia/middleware/benchmark.rb