Firefox Tomorrow

web api instance method

PerformanceObserverEntryList: getEntries() method

View on MDN ↗

Available in workers

The getEntries() method of the PerformanceObserverEntryList interface returns a list of explicitly observed performance entry objects. The list’s members are determined by the set of entry types specified in the call to the observe() method. The list is available in the observer’s callback function (as the first parameter in the callback).

Syntax

getEntries()

Parameters

None.

Return value

A list of explicitly observed PerformanceEntry objects. The items will be in chronological order based on the entries’ startTime. If no objects are found, an empty list is returned.

Examples

Working with getEntries, getEntriesByName and getEntriesByType

The following example shows the difference between the getEntries(), getEntriesByName(), and getEntriesByType() methods.

const observer = new PerformanceObserver((list, obs) => {
  // Log all entries
  let perfEntries = list.getEntries();
  perfEntries.forEach((entry) => {
    console.log(`${entry.name}'s duration: ${entry.duration}`);
  });

  // Log entries named "debugging" with type "measure"
  perfEntries = list.getEntriesByName("debugging", "measure");
  perfEntries.forEach((entry) => {
    console.log(`${entry.name}'s duration: ${entry.duration}`);
  });

  // Log entries with type "mark"
  perfEntries = list.getEntriesByType("mark");
  perfEntries.forEach((entry) => {
    console.log(`${entry.name}'s startTime: ${entry.startTime}`);
  });
});

// Subscribe to various performance event types
observer.observe({
  entryTypes: ["mark", "measure", "navigation", "resource"],
});

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.