ExponentialWeightedAverageStatistic


@UnstableApi
class ExponentialWeightedAverageStatistic : BandwidthStatistic


A BandwidthStatistic that calculates estimates using an exponential weighted average.

Summary

Constants

const Double

The default smoothing factor.

Public constructors

Creates an instance with DEFAULT_SMOOTHING_FACTOR.

Creates an instance.

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.

Constants

DEFAULT_SMOOTHING_FACTOR

const val DEFAULT_SMOOTHING_FACTOR = 0.9999: Double

The default smoothing factor.

Public constructors

ExponentialWeightedAverageStatistic

ExponentialWeightedAverageStatistic()

Creates an instance with DEFAULT_SMOOTHING_FACTOR.

ExponentialWeightedAverageStatistic

ExponentialWeightedAverageStatistic(smoothingFactor: Double)

Creates an instance.

Parameters
smoothingFactor: Double

The exponential smoothing factor.

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.