Sha256: ac3f738ec94863cfec22be03391d1a24ce99ec60df6026766117ea1ef91889ed

Contents?: true

Size: 956 Bytes

Versions: 3

Compression:

Stored size: 956 Bytes

Contents

module Rack
  module Bug
    class RedisPanel
      
      class Stats
        class Query
          attr_reader :time
          attr_reader :command
          
          def initialize(time, *command_args)
            @time = time
            @command = command_args.inspect
          end
          
          def display_time
            "%.2fms" % time
          end
        end
        
        attr_reader :calls
        attr_reader :queries
        
        def initialize
          @queries = []
          @calls = 0
          @time = 0.0
        end
        
        def record_call(time, *command_args)
          @queries << Query.new(time, command_args)
          @calls += 1
          @time += time
        end
        
        def display_time
          "%.2fms" % time
        end
        
        def time
          @queries.inject(0) do |memo, query|
            memo + query.time
          end
        end
      end
      
    end
  end
end

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
jeroenvandijk-rack-bug-0.2.1 lib/rack/bug/panels/redis_panel/stats.rb
wested-rack-bug-0.2.2.1 lib/rack/bug/panels/redis_panel/stats.rb
rack-bug-0.2.1 lib/rack/bug/panels/redis_panel/stats.rb