Class: Insight::RedisPanel::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/insight/panels/redis_panel/stats.rb

Defined Under Namespace

Classes: Query

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStats

Returns 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

#callsObject (readonly)

Returns the value of attribute calls.



22
23
24
# File 'lib/insight/panels/redis_panel/stats.rb', line 22

def calls
  @calls
end

#queriesObject (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

#display_timeObject



37
38
39
# File 'lib/insight/panels/redis_panel/stats.rb', line 37

def display_time
  "%.2fms" % time
end

#record_call(time, command_args, backtrace) ⇒ Object



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

#timeObject



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