measurements option accepts an ordered array of measurement objects. The engine executes each entry in sequence. Every object must include a type field; the remaining fields depend on the type.
Default measurement sequence
When nomeasurements option is provided, the engine runs the following sequence. It follows a ramp-up strategy: file sizes grow progressively so the engine can characterize bandwidth across a range of connection speeds.
The engine applies a ramp-up optimization for
download and upload measurements. Once a request in a given direction takes at least bandwidthFinishRequestDuration milliseconds (default: 1000 ms), all subsequent measurement sets for that direction are skipped. This means slower connections naturally stop at smaller file sizes, while faster connections continue to larger ones. You can disable early stopping by setting bandwidthFinishRequestDuration to 0.Measurement types
latency
Measures unloaded (idle) round-trip latency. Each packet is a GET request to the download API with bytes=0. The round-trip time is extracted from the requestStart → responseStart timing interval provided by the PerformanceResourceTiming API.
Must be
"latency".The number of GET requests to perform. More packets yield a more stable latency estimate. The default sequence uses
1 for an initial quick estimate and 20 for the main measurement.download
Performs a set of download GET requests against downloadApiUrl. Each request fetches a response body of exactly bytes bytes. Bandwidth for each request is calculated as transferSize (bits) / duration (s), where duration excludes server processing time.
Must be
"download".The number of bytes to request. Passed to the download API as a query parameter. Use scientific notation for readability (e.g.,
1e6 for 1 MB, 1e8 for 100 MB).The number of sequential requests to perform at this file size. Multiple requests improve statistical stability at any given size tier.
When
true, the bandwidthMinRequestDuration threshold check is ignored for this measurement set and the engine always proceeds to the next set regardless of how long requests took. Used for the very first download entry in the default sequence to establish an initial estimate on all connection speeds.upload
Performs a set of upload POST requests against uploadApiUrl. Each request posts a body of exactly bytes bytes. Bandwidth calculation mirrors the download type.
Must be
"upload".The number of bytes to post in each request body.
The number of sequential requests to perform at this file size.
When
true, ignores the bandwidthMinRequestDuration check and always continues to the next measurement set.packetLoss
Measures packet loss by sending UDP packets to a WebRTC TURN server in a round-trip fashion, then counting how many packets were not returned. Packets can be sent in batches with configurable inter-batch delays to avoid flooding the connection.
Must be
"packetLoss".Total number of UDP packets to send. The default sequence overrides this to
1000 for greater accuracy.Time in milliseconds to wait after the last received packet before declaring the measurement complete. Any packets not returned within this window are counted as lost. The default sequence uses
3000 ms.Number of packets per batch. If
batchSize is larger than numPackets, all packets are sent in a single batch.Time in milliseconds to wait between consecutive batches.
Time in milliseconds to wait when establishing the connection to the TURN server before giving up.
