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

句法

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

规范

规范 状态 注释
Performance Timeline Level 2
The definition of 'takeRecords()' in that specification.
候选推荐 Initial definition of takeRecords() 方法。

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
takeRecords Chrome 65 Edge ≤79 Firefox 60 IE 不支持 No Opera Yes Safari 不支持 No WebView Android 65 Chrome Android 65 Firefox Android 60 Opera Android Yes Safari iOS 不支持 No Samsung Internet Android 9.0

图例

完整支持

完整支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

元数据

  • 最后修改: