PerformanceTimingConfidence
The PerformanceTimingConfidence interface provides access to information that indicates whether the user agent considers returned navigation metrics to be free from external system load unrelated to the page.
For example, if a website has loaded after a browser "cold start" or session restore, its pages may load more slowly as a result. In such cases, a low confidence value would be returned for an associated performance record. On the other hand, if the browser determines a returned performance record to be representative of typical application performance, a high confidence value is returned.
This confidence measure is useful for developers when trying to determine whether a performance issue is a legitimate concern, or an outlier being caused by external factors.
The PerformanceTimingConfidence object for each navigation timing entry is accessed via the PerformanceNavigationTiming interface's confidence property.
Interpreting confidence data
Since the randomizedTriggerRate can vary across records, per-record weighting is needed to recover unbiased aggregates. The procedure below illustrates how weighting based on value can be applied before computing summary statistics.
To compute debiased means for both high and low values:
- For each record:
- Let
pbe the record'srandomizedTriggerRate. - Let
cbe the record'svalue. - Let
Rbe1whencishigh, otherwise0.
- Let
- Compute per-record weight
wbased onc:- For estimating the
highmean:w = (R - (p / 2)) / (1 - p). - For estimating the
lowmean:w = ((1 - R) - (p / 2)) / (1 - p).Note:
wmay be negative for some records; you should keep every record. - Let
weighted_duration = duration * w(seeduration).
- For estimating the
- Let
total_weighted_durationbe the sum of theweighted_durationvalues across all records. - Let
sum_weightsbe the sum of thewvalues across all records. - Let
debiased_mean = total_weighted_duration / sum_weights, providedsum_weightsis not near zero.
To compute debiased percentiles for both high and low:
- Follow the computing debiased means steps to compute a per-record weight
w. - Let
sum_weightsbe the sum of thewvalues across all records. - Let
sorted_recordsbe all records sorted by duration in ascending order. - For a desired percentile (0-100), compute
q = percentile / 100.0. - Walk
sorted_recordsand for each record:- Compute cumulative weight
cwper-record:cw = sum_{i: duration_i <= duration_j} w_i. - Compute debiased cumulative distribution function per-record:
cdf = cw / sum_weights.
- Compute cumulative weight
- Find the first index
idxwherecdf >= q.- If
idxis0, returndurationforsorted_records[0]. - If no such
idxexists, returndurationforsorted_records[n].
- If
- Compute interpolation fraction:
- Let
lower_cdfbecdfforsorted_records[idx-1]. - Let
upper_cdfbecdfforsorted_records[idx]. - if
lower_cdf = upper_cdf, returndurationforsorted_records[idx]. - Otherwise:
- Let
ifrac = (q - lower_cdf) / (upper_cdf - lower_cdf). - Let
lower_durationbedurationforsorted_records[idx-1]. - Let
upper_durationbedurationforsorted_records[idx]. - Return
lower_duration + (upper_duration - lower_duration) * ifrac.
- Let
- Let
Instance properties
PerformanceTimingConfidence.randomizedTriggerRateRead only-
A number representing a percentage value that indicates how often noise is applied when exposing the
value. PerformanceTimingConfidence.valueRead only-
An enumerated value indicating a broad confidence measure of whether the user agent considers returned navigation metrics to be representative of the current user's device.
Instance methods
PerformanceTimingConfidence.toJSON()-
Returns a JSON representation of the
PerformanceTimingConfidenceobject.
Examples
>Basic usage
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 });
Specifications
| Specification |
|---|
| Navigation Timing Level 2> # sec-performance-timing-confidence> |