Class: Insight::TimerPanel
- Defined in:
- lib/insight/panels/timer_panel.rb
Instance Attribute Summary
Attributes inherited from Panel
Instance Method Summary collapse
- #call(env) ⇒ Object
- #content_for_request(number) ⇒ Object
- #heading_for_request(number) ⇒ Object
-
#initialize(app) ⇒ TimerPanel
constructor
A new instance of TimerPanel.
- #name ⇒ Object
Methods inherited from Panel
#after, #before, current_panel_file, excluded, file_index, from_file, #has_content?, inherited, #panel_app, panel_exclusion, panel_mappings, #render
Methods included from Instrumentation::Client
#after_detect, #before_detect, #probe, #request_finish, #request_start
Methods included from Logging
Methods included from Database::RequestDataClient
#key_sql_template, #retrieve, #store, #table_length, #table_setup
Methods included from Render
#compile, #compile!, #compiled_source, #method_name, #method_name_without_locals, #render_template, #signed_params
Constructor Details
#initialize(app) ⇒ TimerPanel
Returns a new instance of TimerPanel.
5 6 7 8 |
# File 'lib/insight/panels/timer_panel.rb', line 5 def initialize(app) super table_setup("timer") end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/insight/panels/timer_panel.rb', line 14 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 |
#content_for_request(number) ⇒ Object
36 37 38 |
# File 'lib/insight/panels/timer_panel.rb', line 36 def content_for_request(number) render_template "panels/timer", :measurements => retrieve(number).first end |
#heading_for_request(number) ⇒ Object
30 31 32 33 34 |
# File 'lib/insight/panels/timer_panel.rb', line 30 def heading_for_request(number) measurements = retreive(number).first measurements.last.last end |
#name ⇒ Object
10 11 12 |
# File 'lib/insight/panels/timer_panel.rb', line 10 def name "timer" end |