• options {Object}
      • entryTypes {string[]} An array of strings identifying the types of PerformanceEntry instances the observer is interested in. If not provided an error will be thrown.
      • buffered {boolean} If true, the notification callback will be called using setImmediate() and multiple PerformanceEntry instance notifications will be buffered internally. If false, notifications will be immediate and synchronous. Default: false.

    Subscribes the PerformanceObserver instance to notifications of new PerformanceEntry instances identified by options.entryTypes.

    When options.buffered is false, the callback will be invoked once for every PerformanceEntry instance:

    1. const {
    2. performance,
    3. PerformanceObserver
    4. } = require('perf_hooks');
    5. const obs = new PerformanceObserver((list, observer) => {
    6. // Called three times synchronously. `list` contains one item.
    7. });
    8. obs.observe({ entryTypes: ['mark'] });
    9. for (let n = 0; n < 3; n++)
    10. performance.mark(`test${n}`);
    1. const {
    2. performance,
    3. PerformanceObserver
    4. } = require('perf_hooks');
    5. const obs = new PerformanceObserver((list, observer) => {
    6. // Called once. `list` contains three items.
    7. });
    8. obs.observe({ entryTypes: ['mark'], buffered: true });
    9. for (let n = 0; n < 3; n++)
    10. performance.mark(`test${n}`);