PerformanceObserver: takeRecords() method
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.
Note: This feature is available in Web Workers.
The takeRecords()
method of the PerformanceObserver
interface returns the current list of PerformanceEntry
objects stored in the performance observer, emptying it out.
Syntax
js
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.
js
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
Specification |
---|
Performance Timeline # dom-performanceobserver-takerecords |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
takeRecords |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.