PerformanceObserver.takeRecords()

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

Syntax

var performanceEntryList = performanceObserver.takeRecords();

Parameters

None.

Return value

A list of PerformanceEntry objects.

Example

var observer = new PerformanceObserver(function(list, obj) {
  var entries = list.getEntries();
  for (var i=0; i < entries.length; i++) {
    // Process "mark" and "frame" events
  }
});
observer.observe({entryTypes: ["mark", "frame"]});
var records = observer.takeRecords();
console.log(records[0].name);
console.log(records[0].startTime);
console.log(records[0].duration);

Specifications

Specification
Performance Timeline
# dom-performanceobserver-takerecords

Browser compatibility

BCD tables only load in the browser