PercentileTimeToFirstByteEstimator


@UnstableApi
class PercentileTimeToFirstByteEstimator : TimeToFirstByteEstimator


Implementation of TimeToFirstByteEstimator that returns a configured percentile of a sliding window of collected response times.

Summary

Constants

const Int

The default maximum number of samples.

const Float

The default percentile to return.

Public constructors

Creates an instance that keeps up to DEFAULT_MAX_SAMPLES_COUNT samples and returns the DEFAULT_PERCENTILE percentile.

PercentileTimeToFirstByteEstimator(
    numberOfSamples: Int,
    percentile: Float
)

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_MAX_SAMPLES_COUNT

const val DEFAULT_MAX_SAMPLES_COUNT = 10: Int

The default maximum number of samples.

DEFAULT_PERCENTILE

const val DEFAULT_PERCENTILE = 0.5f: Float

The default percentile to return.

Public constructors

PercentileTimeToFirstByteEstimator

PercentileTimeToFirstByteEstimator()

Creates an instance that keeps up to DEFAULT_MAX_SAMPLES_COUNT samples and returns the DEFAULT_PERCENTILE percentile.

PercentileTimeToFirstByteEstimator

PercentileTimeToFirstByteEstimator(
    numberOfSamples: Int,
    percentile: Float
)

Creates an instance.

Parameters
numberOfSamples: Int

The maximum number of samples to be kept in the sliding window.

percentile: Float

The percentile for estimating the time to the first byte.

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.