Documentation/PerformanceObserver
classWORKER

PerformanceObserver

js/performance.js:102
PerformanceObserver(callback)

Creates a new observer for entries added to the JSplitter performance timeline.

The callback is invoked asynchronously when performance.mark or performance.measure records an entry whose type is currently observed. Entries created in the same event-loop burst may be delivered together in one callback.
JSplitter currently supports only the "mark" and "measure" entry types. The Web Performance Timeline buffered option is not implemented.

Parameters

NameTypeDescription
callbackPerformanceObserverCallback

Callback invoked when matching entries are delivered.

Example source

propertyWORKERreadonly

supportedEntryTypes

js/performance.js:113
supportedEntryTypes: Array<string> = PerformanceObserver.supportedEntryTypes

JSplitter compatibility alias for the standard static PerformanceObserver.supportedEntryTypes property.
Returns the same frozen array object as the static property.

methodWORKER

disconnect

js/performance.js:150
disconnect()

Stops delivery of future performance entries, clears pending observer records, and resets the observer's registered entry types.
The same observer may be configured again with observe after disconnecting.

methodWORKER

observe

js/performance.js:122
observe(options)

Registers performance entry types to observe.

Use either entryTypes or type for a given observer until disconnect is called. Switching between the two modes throws an error.
Repeated calls using the same mode add supported types to the observer's current set. Unsupported entry types are ignored.
JSplitter currently supports only entryTypes and type; the Web Performance Timeline buffered option is not implemented.

Parameters

NameTypeDescription
optionsPerformanceObserverOptions

Observer options.

Throws

Error —

If options is not an object or if the observer switches between entryTypes and type modes without first calling disconnect.

Example

function perfObserver(list, observer) {
  list.getEntries().forEach((entry) => {
    if (entry.entryType === "mark") {
      console.log(`${entry.name}'s startTime: ${entry.startTime}`);
    }
    if (entry.entryType === "measure") {
      console.log(`${entry.name}'s duration: ${entry.duration}`);
    }
  });
}

const observer = new PerformanceObserver(perfObserver);
observer.observe({ entryTypes: ["mark", "measure"] });
methodWORKER

takeRecords

js/performance.js:158
takeRecords()

Returns the performance entries currently waiting in the observer buffer and empties that buffer.
Entries returned by this method will not later be delivered by the callback.

Returns

Array<PerformanceEntry>