Class: Rack::Bug::RedisPanel::Stats
- Inherits:
-
Object
- Object
- Rack::Bug::RedisPanel::Stats
- Defined in:
- lib/rack/bug/panels/redis_panel/stats.rb
Defined Under Namespace
Classes: Query
Instance Attribute Summary collapse
-
#calls ⇒ Object
readonly
Returns the value of attribute calls.
-
#queries ⇒ Object
readonly
Returns the value of attribute queries.
Instance Method Summary collapse
- #display_time ⇒ Object
-
#initialize ⇒ Stats
constructor
A new instance of Stats.
- #record_call(time, command_args, backtrace) ⇒ Object
- #time ⇒ Object
Constructor Details
#initialize ⇒ Stats
Returns a new instance of Stats.
26 27 28 29 30 |
# File 'lib/rack/bug/panels/redis_panel/stats.rb', line 26 def initialize @queries = [] @calls = 0 @time = 0.0 end |
Instance Attribute Details
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
23 24 25 |
# File 'lib/rack/bug/panels/redis_panel/stats.rb', line 23 def calls @calls end |
#queries ⇒ Object (readonly)
Returns the value of attribute queries.
24 25 26 |
# File 'lib/rack/bug/panels/redis_panel/stats.rb', line 24 def queries @queries end |
Instance Method Details
#display_time ⇒ Object
38 39 40 |
# File 'lib/rack/bug/panels/redis_panel/stats.rb', line 38 def display_time "%.2fms" % time end |
#record_call(time, command_args, backtrace) ⇒ Object
32 33 34 35 36 |
# File 'lib/rack/bug/panels/redis_panel/stats.rb', line 32 def record_call(time, command_args, backtrace) @queries << Query.new(time, command_args, backtrace) @calls += 1 @time += time end |
#time ⇒ Object
42 43 44 45 46 |
# File 'lib/rack/bug/panels/redis_panel/stats.rb', line 42 def time @queries.inject(0) do |memo, query| memo + query.time end end |