ExponentialWeightedAverageTimeToFirstByteEstimator


@UnstableApi
public final class ExponentialWeightedAverageTimeToFirstByteEstimator implements TimeToFirstByteEstimator


Implementation of TimeToFirstByteEstimator based on exponential weighted average.

Summary

Constants

static final double

The default smoothing factor.

Public constructors

Creates an instance using the DEFAULT_SMOOTHING_FACTOR.

Creates an instance.

Public methods

long

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

void

Called when a transfer is being initialized.

void

Called when a transfer starts.

void

Resets the estimator.

Constants

DEFAULT_SMOOTHING_FACTOR

public static final double DEFAULT_SMOOTHING_FACTOR = 0.85

The default smoothing factor.

Public constructors

ExponentialWeightedAverageTimeToFirstByteEstimator

public ExponentialWeightedAverageTimeToFirstByteEstimator()

Creates an instance using the DEFAULT_SMOOTHING_FACTOR.

ExponentialWeightedAverageTimeToFirstByteEstimator

public ExponentialWeightedAverageTimeToFirstByteEstimator(
    double smoothingFactor
)

Creates an instance.

Parameters
double smoothingFactor

The exponential weighted average smoothing factor.

Public methods

getTimeToFirstByteEstimateUs

public long getTimeToFirstByteEstimateUs()

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

onTransferInitializing

public void onTransferInitializing(DataSpec dataSpec)

Called when a transfer is being initialized.

Parameters
DataSpec dataSpec

Describes the data for which the transfer is initialized.

onTransferStart

public void onTransferStart(DataSpec dataSpec)

Called when a transfer starts.

Parameters
DataSpec dataSpec

Describes the data being transferred.

reset

public void reset()

Resets the estimator.