Sha256: 755afcca9bd1d06703780311164db6a5c3f6d5fa8677dcb7b249bc5381560567

Contents?: true

Size: 814 Bytes

Versions: 20

Compression:

Stored size: 814 Bytes

Contents

require 'benchmark'

module Rack::Insight
  class TimerPanel < Panel

    def call(env)
      status, headers, body = nil
      @times = Benchmark.measure do
        status, headers, body = @app.call(env)
      end

      store(env, [
            ["User CPU time",   "%.2fms" % (@times.utime * 1_000)],
            ["System CPU time", "%.2fms" % (@times.stime * 1_000)],
            ["Total CPU time",  "%.2fms" % (@times.total * 1_000)],
            ["Elapsed time",    "%.2fms" % (@times.real  * 1_000)]
      ])

      return [status, headers, body]
    end

    def heading_for_request(number)
      measurements = retrieve(number).first

      measurements.last.last
    end

    def content_for_request(number)
      render_template "panels/timer", :measurements => retrieve(number).first
    end

  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
rack-insight-0.6.4 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.6.3 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.6.2 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.5.30 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.5.29 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.5.28 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.5.27 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.5.26 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.5.25 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.5.24 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.5.23 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.5.22 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.5.21 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.5.20 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.5.19 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.5.18 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.5.17 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.5.16 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.5.15 lib/rack/insight/panels/timer_panel.rb
rack-insight-0.5.14 lib/rack/insight/panels/timer_panel.rb