Kiss A simpler, smarter web application framework for Ruby

Rack::Bench Subclass of Object

Methods

Description

Rack::Bench shows total request duration for any request.

Public Class Methods

new(app) source

Not documented

    # File lib/kiss/rack/bench.rb, line 9
    def initialize(app)
      @app = app
    end
    

Public Instance Methods

call(env) source

Not documented

    # File lib/kiss/rack/bench.rb, line 13
    def call(env)
      start_time = Time.now
      code, headers, body = @app.call(env)
      end_time = Time.now
      
      contents = "<style>\n.kiss_bench {\ntext-align: left;\npadding: 3px 7px;\nborder: 1px solid #ec4;\nborder-top: 1px solid #fff4bb;\nborder-bottom: 1px solid #d91;\nbackground-color: #ffe590;\nfont-size: 12px;\ncolor: #101;\n}\n.kiss_bench a {\ncolor: #930;\ntext-decoration: none;\n}\n.kiss_bench a:hover {\ncolor: #930;\ntext-decoration: underline;\n}\n</style>\n<div class=\"kiss_bench\">\n<tt><b>TOTAL request duration: \#{sprintf(\"%0.3f\",end_time.to_f - start_time.to_f)} s</b></tt>\n<br><small>kiss bench request total</small>\n</div>\n"
      
      body.each {|p| contents += p }
      headers['Content-Length'] = contents.length.to_s
    
      [ code, headers, contents ]
    end
    

Disabled; run with $DEBUG to generate this.