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:

  1. For each record:
  2. Compute per-record weight w based on c:
    • For estimating the high mean: w = (R - (p / 2)) / (1 - p).
    • For estimating the low mean: w = ((1 - R) - (p / 2)) / (1 - p).

      Note: w may be negative for some records; you should keep every record.

    • Let weighted_duration = duration * w (see duration).
  3. Let total_weighted_duration be the sum of the weighted_duration values across all records.
  4. Let sum_weights be the sum of the w values across all records.
  5. Let debiased_mean = total_weighted_duration / sum_weights, provided sum_weights is not near zero.

To compute debiased percentiles for both high and low:

  1. Follow the computing debiased means steps to compute a per-record weight w.
  2. Let sum_weights be the sum of the w values across all records.
  3. Let sorted_records be all records sorted by duration in ascending order.
  4. For a desired percentile (0-100), compute q = percentile / 100.0.
  5. Walk sorted_records and for each record:
    • Compute cumulative weight cw per-record: cw = sum_{i: duration_i <= duration_j} w_i.
    • Compute debiased cumulative distribution function per-record: cdf = cw / sum_weights.
  6. Find the first index idx where cdf >= q.
    • If idx is 0, return duration for sorted_records[0].
    • If no such idx exists, return duration for sorted_records[n].
  7. Compute interpolation fraction:
    • Let lower_cdf be cdf for sorted_records[idx-1].
    • Let upper_cdf be cdf for sorted_records[idx].
    • if lower_cdf = upper_cdf, return duration for sorted_records[idx].
    • Otherwise:
      • Let ifrac = (q - lower_cdf) / (upper_cdf - lower_cdf).
      • Let lower_duration be duration for sorted_records[idx-1].
      • Let upper_duration be duration for sorted_records[idx].
      • Return lower_duration + (upper_duration - lower_duration) * ifrac.

Instance properties

PerformanceTimingConfidence.randomizedTriggerRate Read only

A number representing a percentage value that indicates how often noise is applied when exposing the value.

PerformanceTimingConfidence.value Read 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 PerformanceTimingConfidence object.

Examples

Basic usage

This example uses a PerformanceObserver to retrieve confidence data from observed PerformanceNavigationTiming entries.

js
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

Browser compatibility

See also