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.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
takeRecords
Experimental
Chrome Full support 65Edge ? Firefox Full support 60IE No support NoOpera Full support YesSafari No support NoWebView Android Full support 65Chrome Android Full support 65Edge Mobile ? Firefox Android Full support 60Opera Android Full support YesSafari iOS No support NoSamsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.

文档标签和贡献者

此页面的贡献者: Pada
最后编辑者: Pada,