module Rack # Deprecated. Benchmarks output now prepended at end of Kiss#call. # This module is kept for benchmarking full request operation time; # this should be moved to Kiss#call as well. Then remove this module # for Kiss 1.1. # Rack::Bench shows total request duration for any request. class Bench def initialize(app) @app = app end def call(env) start_time = Time.now code, headers, body = @app.call(env) end_time = Time.now contents = <<-EOT
TOTAL request duration: #{sprintf("%0.3f",end_time.to_f - start_time.to_f)} s
kiss bench request total
EOT body.each {|p| contents += p } headers['Content-Length'] = contents.length.to_s [ code, headers, contents ] end end end