Class: Rack::Bug::TimerPanel
- Inherits:
-
Panel
- Object
- Panel
- Rack::Bug::TimerPanel
show all
- Defined in:
- lib/rack/bug/panels/timer_panel.rb
Instance Attribute Summary
Attributes inherited from Panel
#request
Instance Method Summary
collapse
Methods inherited from Panel
#after, #before, #has_content?, #initialize, #panel_app, #render
Methods included from Render
#compile, #compile!, #compiled_source, #method_name, #method_name_without_locals, #render_template, #signed_params
Instance Method Details
#call(env) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/rack/bug/panels/timer_panel.rb', line 13
def call(env)
status, , body = nil
@times = Benchmark.measure do
status, , body = @app.call(env)
end
@measurements = [
["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)]
]
env["rack-bug.panels"] << self
return [status, , body]
end
|
#content ⇒ Object
34
35
36
|
# File 'lib/rack/bug/panels/timer_panel.rb', line 34
def content
render_template "panels/timer", :measurements => @measurements
end
|
#heading ⇒ Object
30
31
32
|
# File 'lib/rack/bug/panels/timer_panel.rb', line 30
def heading
"%.2fms" % (@times.real * 1_000)
end
|
#name ⇒ Object
9
10
11
|
# File 'lib/rack/bug/panels/timer_panel.rb', line 9
def name
"timer"
end
|