-
- All Implemented Interfaces:
public class RateTrackerTracks an average rate (of values added via update) over a sliding window. The data is kept in a circular buffer of buckets with a configurable size, which can be efficient in both CPU and memory use. Useful for e.g. calculating the bitrate or packet rate of a stream.
-
-
Constructor Summary
Constructors Constructor Description RateTracker(Duration windowSize, Duration bucketSize, Clock clock)RateTracker(Duration windowSize, Duration bucketSize)RateTracker(Duration windowSize)RateTracker(Integer numBuckets, Duration bucketSize, Clock clock)RateTracker(Integer numBuckets, Duration bucketSize)RateTracker(Integer numBuckets)
-
Method Summary
-
-
Method Detail
-
getRate
@Synchronized() Long getRate(Long nowMs)
Get the rate in units per second.
-
getAccumulatedCount
@Synchronized()@JvmOverloads() final Long getAccumulatedCount(Long nowMs)
-
getAccumulatedCount
@Synchronized()@JvmOverloads() final Long getAccumulatedCount()
-
update
@Synchronized()@JvmOverloads() final Unit update(Long count, Long nowMs)
-
update
@Synchronized()@JvmOverloads() final Unit update(Long count)
-
update
@Synchronized()@JvmOverloads() final Unit update()
-
-
-
-