Sha256: f3ef4de45bee5b21baab1e55bde68910798f3e1e630ab83c54a5246285b86606

Contents?: true

Size: 995 Bytes

Versions: 5

Compression:

Stored size: 995 Bytes

Contents

module Rack::Insight
  class RedisPanel

    class Stats
      class Query
        include Rack::Insight::FilteredBacktrace

        attr_reader :time
        attr_reader :command

        def initialize(time, command_args, method_call)
          @time = time
          @command = command_args.inspect
          @backtrace = method_call.backtrace
        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, method_call)
        @queries << Query.new(time, command_args, method_call)
        #puts "Recorded Redis Call: #{@queries.inspect}"
        @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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rack-insight-0.6.4 lib/rack/insight/panels/redis_panel/stats.rb
rack-insight-0.6.3 lib/rack/insight/panels/redis_panel/stats.rb
rack-insight-0.6.2 lib/rack/insight/panels/redis_panel/stats.rb
rack-insight-0.5.30 lib/rack/insight/panels/redis_panel/stats.rb
rack-insight-0.5.29 lib/rack/insight/panels/redis_panel/stats.rb