Sha256: bb48b90116fd1d91353be9305f2ebc7f03713023f6b106dcc25be3f1d0ba1c10

Contents?: true

Size: 635 Bytes

Versions: 31

Compression:

Stored size: 635 Bytes

Contents

#	This file is part of the "Utopia Framework" project, and is licensed under the GNU AGPLv3.
#	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

31 entries across 31 versions & 1 rubygems

Version Path
utopia-0.9.58 lib/utopia/middleware/benchmark.rb
utopia-0.9.57 lib/utopia/middleware/benchmark.rb
utopia-0.9.56 lib/utopia/middleware/benchmark.rb
utopia-0.9.55 lib/utopia/middleware/benchmark.rb
utopia-0.9.54 lib/utopia/middleware/benchmark.rb
utopia-0.9.53 lib/utopia/middleware/benchmark.rb
utopia-0.9.52 lib/utopia/middleware/benchmark.rb
utopia-0.9.51 lib/utopia/middleware/benchmark.rb
utopia-0.9.50 lib/utopia/middleware/benchmark.rb
utopia-0.9.49 lib/utopia/middleware/benchmark.rb
utopia-0.9.48 lib/utopia/middleware/benchmark.rb
utopia-0.9.47 lib/utopia/middleware/benchmark.rb
utopia-0.9.46 lib/utopia/middleware/benchmark.rb
utopia-0.9.45 lib/utopia/middleware/benchmark.rb
utopia-0.9.43 lib/utopia/middleware/benchmark.rb
utopia-0.9.42 lib/utopia/middleware/benchmark.rb
utopia-0.9.41 lib/utopia/middleware/benchmark.rb
utopia-0.9.40 lib/utopia/middleware/benchmark.rb
utopia-0.9.39 lib/utopia/middleware/benchmark.rb
utopia-0.9.38 lib/utopia/middleware/benchmark.rb