webrtc_cc_rate (webrtc v0.1.0)
View SourceBit rate over a sliding time window, in one-millisecond buckets.
add/3 records bytes at a time in milliseconds and rate/2 returns the bit rate over the window ending at a time. A sample older than the newest bucket is merged into it (reordering by a few milliseconds does not matter at the window scale). The rate is undefined until the first sample is a whole window old, so a short burst at start is not reported as a high rate. Memory is bounded by the window length: at most one bucket per millisecond.
Summary
Types
Functions
-spec add(integer(), non_neg_integer(), rate()) -> rate().
-spec bytes(integer(), rate()) -> non_neg_integer().
Bytes recorded in (T - window, T].
-spec new(pos_integer()) -> rate().
-spec rate(integer(), rate()) -> non_neg_integer() | undefined.
Bits per second over (T - window, T].