Sha256: 0acec6a08131c1ca10f3cc23b41307313ee31fda1fce6b9aea59e418af1fff3c
Contents?: true
Size: 542 Bytes
Versions: 15
Compression:
Stored size: 542 Bytes
Contents
module PulseMeter module Sensor module Timelined # Calculates n'th percentile in interval class Percentile < ZSetBased attr_reader :p_value def initialize(name, options) @p_value = assert_ranged_float!(options, :p, 0, 1) super(name, options) end def calculate(key, count) position = @p_value > 0 ? (@p_value * count).round - 1 : 0 el = redis.zrange(key, position, position)[0] redis.zscore(key, el) end end end end end
Version data entries
15 entries across 15 versions & 2 rubygems