PerformanceObserverEntryList: getEntries() メソッド

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.

getEntries()PerformanceObserverEntryList インターフェイスのメソッドで、明示的に監視されたパフォーマンス項目オブジェクトのリストを返します。このリストのメンバーは、observe() メソッドを呼んで指定された項目型のセットによって決定されます。このリストは、オブザーバーのコールバック関数(コールバックの最初の引数)で利用できます。

構文

js
getEntries()

返値

明示的に監視された PerformanceEntry オブジェクトのリスト。項目は、項目のstartTime に基づいて時系列順に整列されます。 オブジェクトが見つからない場合は、空のリストが返されます。

getEntries, getEntriesByName, getEntriesByType の扱い

次の例は、getEntries()getEntriesByName()getEntriesByType() の各メソッドの違いを示しています。

js
const observer = new PerformanceObserver((list, obs) => {
  // すべての項目をログ出力
  let perfEntries = list.getEntries();
  perfEntries.forEach((entry) => {
    console.log(`${entry.name} の時間: ${entry.duration}`);
  });

  // "debugging" という名前の "measure" 型の項目をログ出力
  perfEntries = list.getEntriesByName("debugging", "measure");
  perfEntries.forEach((entry) => {
    console.log(`${entry.name} の時間: ${entry.duration}`);
  });

  // "mark" 型の項目をログ出力
  perfEntries = list.getEntriesByType("mark");
  perfEntries.forEach((entry) => {
    console.log(`${entry.name} の開始時刻: ${entry.startTime}`);
  });
});

// さまざまなパフォーマンスイベント型を監視
observer.observe({
  entryTypes: ["mark", "measure", "navigation", "resource"],
});

仕様書

Specification
Performance Timeline
# dom-performanceobserverentrylist-getentries

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
getEntries

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support