Sha256: 417b8377aa9957847550afbc4573ef2936d66f54cee42f3b81102ee723311ef5
Contents?: true
Size: 1.31 KB
Versions: 14
Compression:
Stored size: 1.31 KB
Contents
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 <style> .kiss_bench { text-align: left; padding: 3px 7px; border: 1px solid #ec4; border-top: 1px solid #fff4bb; border-bottom: 1px solid #d91; background-color: #ffe590; font-size: 12px; color: #101; } .kiss_bench a { color: #930; text-decoration: none; } .kiss_bench a:hover { color: #930; text-decoration: underline; } .kiss_bench small { font-family: arial, sans-serif; float: right; margin-left: 8px; color: #a60; text-align: right; white-space: nowrap; } </style> <div class="kiss_bench"> <small>kiss bench</small> <tt><b>TOTAL request duration: #{sprintf("%0.3f", end_time.to_f - start_time.to_f)} s</b></tt> </div> EOT body = body.prepend_html(html, 'body') headers['Content-Length'] = body.content_length.to_s [ code, headers, body ] end end end
Version data entries
14 entries across 14 versions & 1 rubygems