Firefox Tomorrow

web api instance method

PerformanceObserver: takeRecords() method

View on MDN ↗

Available in workers

The takeRecords() method of the PerformanceObserver interface returns the current list of PerformanceEntry objects stored in the performance observer, emptying it out.

Syntax

takeRecords()

Parameters

None.

Return value

A list of PerformanceEntry objects.

Examples

Taking records

The following example stores the current list of performance entries into records and empties the performance observer.

const observer = new PerformanceObserver((list, obj) => {
  list.getEntries().forEach((entry) => {
    // Process "mark" and "measure" events
  });
});
observer.observe({ entryTypes: ["mark", "measure"] });
const records = observer.takeRecords();
console.log(records[0].name);
console.log(records[0].startTime);
console.log(records[0].duration);

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.