Function: getBandwidthBps()
ts
function getBandwidthBps(sample): number;Defined in: getBandwidthBps.ts:18
Converts a ResourceTiming sample to bandwidth in bits per second.
The rate is the body size over the transfer duration from getTransferDuration. When the sample has responseStart, the wait for the first byte does not count.
Parameters
sample
A ResourceTiming sample
Returns
number
The bandwidth in bits per second.
Example
ts
// 112 kB that waited 800 ms for the first byte and transferred in 50 ms.
const bandwidthBps = getBandwidthBps({
startTime: 0,
responseStart: 800,
duration: 850,
encodedBodySize: 112_000,
})
equal(bandwidthBps, 17_920_000)