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 html = <<-EOT
kiss bench TOTAL request duration: #{sprintf("%0.3f", end_time.to_f - start_time.to_f)} s
EOT body = body.prepend_html(html, 'body') headers['Content-Length'] = body.content_length.to_s [ code, headers, body ] end end end