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