ExponentialWeightedAverageTimeToFirstByteEstimator


@UnstableApi
class ExponentialWeightedAverageTimeToFirstByteEstimator : TimeToFirstByteEstimator


Implementation of TimeToFirstByteEstimator based on exponential weighted average.

Summary

Constants

const Double

The default smoothing factor.

Public constructors

Creates an instance using the DEFAULT_SMOOTHING_FACTOR.

Creates an instance.

Public functions

Long

Returns the estimated time to first byte of the response body, in microseconds, or TIME_UNSET if no estimate is available.

Unit

Called when a transfer is being initialized.

Unit

Called when a transfer starts.

Unit

Resets the estimator.

Constants

DEFAULT_SMOOTHING_FACTOR

const val DEFAULT_SMOOTHING_FACTOR = 0.85: Double

The default smoothing factor.

Public constructors

ExponentialWeightedAverageTimeToFirstByteEstimator

ExponentialWeightedAverageTimeToFirstByteEstimator()

Creates an instance using the DEFAULT_SMOOTHING_FACTOR.

ExponentialWeightedAverageTimeToFirstByteEstimator

ExponentialWeightedAverageTimeToFirstByteEstimator(
    smoothingFactor: Double
)

Creates an instance.

Parameters
smoothingFactor: Double

The exponential weighted average smoothing factor.

Public functions

getTimeToFirstByteEstimateUs

fun getTimeToFirstByteEstimateUs(): Long

Returns the estimated time to first byte of the response body, in microseconds, or TIME_UNSET if no estimate is available.

onTransferInitializing

fun onTransferInitializing(dataSpec: DataSpec!): Unit

Called when a transfer is being initialized.

Parameters
dataSpec: DataSpec!

Describes the data for which the transfer is initialized.

onTransferStart

fun onTransferStart(dataSpec: DataSpec!): Unit

Called when a transfer starts.

Parameters
dataSpec: DataSpec!

Describes the data being transferred.

reset

fun reset(): Unit

Resets the estimator.