BandwidthStatistic


@UnstableApi
interface BandwidthStatistic

Known direct subclasses
ExponentialWeightedAverageStatistic

A BandwidthStatistic that calculates estimates using an exponential weighted average.

SlidingPercentileBandwidthStatistic

A BandwidthStatistic that calculates estimates based on a sliding window weighted percentile.

SlidingWeightedAverageBandwidthStatistic

A BandwidthStatistic that calculates estimates based on a sliding window weighted average.


The interface for different bandwidth estimation statistics.

Summary

Public functions

Unit
addSample(bytes: Long, durationUs: Long)

Adds a transfer sample to the statistic.

Long

Returns the bandwidth estimate in bits per second, or ESTIMATE_NOT_AVAILABLE if there is no estimate available yet.

Unit

Resets the statistic.

Public functions

addSample

fun addSample(bytes: Long, durationUs: Long): Unit

Adds a transfer sample to the statistic.

Parameters
bytes: Long

The number of bytes transferred.

durationUs: Long

The duration of the transfer, in microseconds.

getBandwidthEstimate

fun getBandwidthEstimate(): Long

Returns the bandwidth estimate in bits per second, or ESTIMATE_NOT_AVAILABLE if there is no estimate available yet.

reset

fun reset(): Unit

Resets the statistic. The statistic should drop all samples and reset to its initial state, similar to right after construction.