PerformanceObserver.takeRecords()

 

PerformanceObserver 接口的 takeRecords() 方法返回当前存储在性能观察器中的 性能条目  列表,将其清空。

Syntax

var PerformanceEntry[] = performanceObserver.takeRecords();

参数

None.

返回值

PerformanceEntry 对象列表.

例子

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);

规范

Specification Status Comment
Performance Timeline Level 2
takeRecords()
Candidate Recommendation Initial definition of takeRecords() method.

浏览器兼容性

BCD tables only load in the browser