Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The PerformanceTimingConfidence interface provides access to information that indicates whether a performance record reflects typical application performance, or is likely affected by external factors.
The PerformanceTimingConfidence object for each navigation timing entry is accessed via the PerformanceNavigationTiming interface's confidence property.
PerformanceTimingConfidence.randomizedTriggerRate Read only A number indicating how often noise is applied when exposing the value.
PerformanceTimingConfidence.value Read only An enumerated value indicating a broad confidence measure of whether a performance record reflects typical application performance, or is likely affected by external factors.
PerformanceTimingConfidence.toJSON() Returns a JSON representation of the PerformanceTimingConfidence object.
If a website has loaded after a browser "cold start" or session restore, its pages may load more slowly as a result. This can cause a significant difference between real-world dashboard metrics and performance observations in page profiling tools, making it hard for a developer to understand whether a performance issue is a legitimate concern or an outlier caused by external factors.
The PerformanceTimingConfidence interface allows developers to compensate for this problem by returning a browser estimate (in the value property) of the likelihood that a returned performance record represents typical application performance. This is a value of either "low" or "high", indicating the browser's confidence in the measurement.
Note: Device factors such as CPU do not contribute to the performance assessment. Other factors than browser "cold start" and session restore may be taken into account in future updates.
To reduce the possibility of using the value for fingerprinting, noise is added to the estimate, meaning the value will deliberately be wrong for some proportion of results. The trigger rate for the noise is given in the randomizedTriggerRate property.
Since this can vary across records, per-record weighting is needed to recover unbiased aggregates, to improve data consistency, reduce the number of compound errors, and generally to produce a baseline against which the measured results can be evaluated.
You should use the data as follows to extract meaningful information from the randomized values:
PerformanceNavigationTiming records, collect randomizedTriggerRate and value for each record.The procedures below illustrate how weighting based on value can be applied before computing summary statistics based on the confidence data.
To compute debiased means for both high and low values:
p be the record's randomizedTriggerRate.c be the record's value.R be 1 when c is high, otherwise 0.w based on c:high mean: w = (R - (p / 2)) / (1 - p).low mean: w = ((1 - R) - (p / 2)) / (1 - p).Note: w may be negative for some records; you should keep every record.
weighted_duration = duration * w (see duration).total_weighted_duration be the sum of the weighted_duration values across all records.sum_weights be the sum of the w values across all records.debiased_mean = total_weighted_duration / sum_weights, provided sum_weights is not near zero.To compute debiased percentiles for both high and low:
w.sum_weights be the sum of the w values across all records.sorted_records be all records sorted by duration in ascending order.q = percentile / 100.0.sorted_records and for each record:cw per-record: cw = sum_{i: duration_i <= duration_j} w_i.cdf = cw / sum_weights.idx where cdf >= q.idx is 0, return duration for sorted_records[0].idx exists, return duration for sorted_records[n].lower_cdf be cdf for sorted_records[idx-1].upper_cdf be cdf for sorted_records[idx].lower_cdf = upper_cdf, return duration for sorted_records[idx].ifrac = (q - lower_cdf) / (upper_cdf - lower_cdf).lower_duration be duration for sorted_records[idx-1].upper_duration be duration for sorted_records[idx].lower_duration + (upper_duration - lower_duration) * ifrac.This example uses a PerformanceObserver to retrieve confidence data from observed PerformanceNavigationTiming entries.
const observer = new PerformanceObserver((list) => {
list.getEntries().forEach((entry) => {
console.log(
`${entry.name} confidence: ${entry.confidence.value}`,
`Trigger rate: ${entry.confidence.randomizedTriggerRate}`,
);
});
});
observer.observe({ type: "navigation", buffered: true });