PerformanceObserver.takeRecords()

PerformanceObserver インターフェイスの takeRecords() メソッドは、パフォーマンスオブザーバーに格納されているパフォーマンスエントリの現在のリストを空にして返します。

構文

var PerformanceEntry[] = performanceObserver.takeRecords();

引数

なし

返値

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
Performance Timeline
# dom-performanceobserver-takerecords

ブラウザーの互換性

BCD tables only load in the browser