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
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/rack/bug/panels/timer_panel.rb', line 12
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
33
34
35
|
# File 'lib/rack/bug/panels/timer_panel.rb', line 33
def content
render_template "panels/timer", :measurements => @measurements
end
|
#heading ⇒ Object
29
30
31
|
# File 'lib/rack/bug/panels/timer_panel.rb', line 29
def heading
"%.2fms" % (@times.real * 1_000)
end
|
#name ⇒ Object
8
9
10
|
# File 'lib/rack/bug/panels/timer_panel.rb', line 8
def name
"timer"
end
|