Skip to content

Function: getTransferDuration() ​

ts
function getTransferDuration(sample): number;

Defined in: getTransferDuration.ts:18

Returns the milliseconds a response body took to transfer.

When responseStart is a finite number between startTime and the end of the response, the function returns the time from responseStart to the end. The wait for the first byte is not part of the transfer. Otherwise the function returns duration.

Parameters ​

sample ​

ResourceTiming

A ResourceTiming sample

Returns ​

number

The transfer duration in milliseconds

Example ​

ts
// 800 ms to the first byte, then a 50 ms transfer.
const transferDuration = getTransferDuration({
	startTime: 1000,
	responseStart: 1800,
	duration: 850,
	encodedBodySize: 112_000,
})

equal(transferDuration, 50)

A Streaming Video Technology Alliance project.