Sha256: 4ec09766c526a8b0474c2129158a902f0177b0702126fd01f4734112739528bd

Contents?: true

Size: 775 Bytes

Versions: 34

Compression:

Stored size: 775 Bytes

Contents

module Rack::Insight
  class MongoPanel

    class Stats
      class Query
        attr_reader :time
        attr_reader :command

        def initialize(time, command)
          @time = time
          @command = command
        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)
        @queries << Query.new(time, command)
        @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

34 entries across 34 versions & 1 rubygems

Version Path
rack-insight-0.6.4 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.6.3 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.6.2 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.5.30 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.5.29 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.5.28 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.5.27 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.5.26 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.5.25 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.5.24 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.5.23 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.5.22 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.5.21 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.5.20 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.5.19 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.5.18 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.5.17 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.5.16 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.5.15 lib/rack/insight/panels/mongo_panel/stats.rb
rack-insight-0.5.14 lib/rack/insight/panels/mongo_panel/stats.rb