Skip to main content
PerformanceObserverEntryList.prototype.getEntriesByType - perf_hooks - Node documentation
method PerformanceObserverEntryList.prototype.getEntriesByType

Usage in Deno

import { PerformanceObserverEntryList } from "node:perf_hooks";
PerformanceObserverEntryList.prototype.getEntriesByType(type: EntryType): PerformanceEntry[]

Returns a list of PerformanceEntry objects in chronological order with respect to performanceEntry.startTime whose performanceEntry.entryType is equal to type.

import {
  performance,
  PerformanceObserver,
} from 'node:perf_hooks';

const obs = new PerformanceObserver((perfObserverList, observer) => {
  console.log(perfObserverList.getEntriesByType('mark'));

   * [
   *   PerformanceEntry {
   *     name: 'test',
   *     entryType: 'mark',
   *     startTime: 55.897834,
   *     duration: 0,
   *     detail: null
   *   },
   *   PerformanceEntry {
   *     name: 'meow',
   *     entryType: 'mark',
   *     startTime: 56.350146,
   *     duration: 0,
   *     detail: null
   *   }
   * ]

  performance.clearMarks();
  performance.clearMeasures();
  observer.disconnect();
});
obs.observe({ type: 'mark' });

performance.mark('test');
performance.mark('meow');

Parameters

type: EntryType

Return Type