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) ⇒ Object
- #time ⇒ Object
Constructor Details
#initialize ⇒ Stats
Returns a new instance of Stats.
23 24 25 26 27 |
# File 'lib/rack/bug/panels/redis_panel/stats.rb', line 23 def initialize @queries = [] @calls = 0 @time = 0.0 end |
Instance Attribute Details
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
20 21 22 |
# File 'lib/rack/bug/panels/redis_panel/stats.rb', line 20 def calls @calls end |
#queries ⇒ Object (readonly)
Returns the value of attribute queries.
21 22 23 |
# File 'lib/rack/bug/panels/redis_panel/stats.rb', line 21 def queries @queries end |
Instance Method Details
#display_time ⇒ Object
35 36 37 |
# File 'lib/rack/bug/panels/redis_panel/stats.rb', line 35 def display_time "%.2fms" % time end |
#record_call(time, *command_args) ⇒ Object
29 30 31 32 33 |
# File 'lib/rack/bug/panels/redis_panel/stats.rb', line 29 def record_call(time, *command_args) @queries << Query.new(time, command_args) @calls += 1 @time += time end |
#time ⇒ Object
39 40 41 42 43 |
# File 'lib/rack/bug/panels/redis_panel/stats.rb', line 39 def time @queries.inject(0) do |memo, query| memo + query.time end end |