PerformanceEntry - Web APIs | MDN

Instance properties

PerformanceEntry.name Read only

A string representing the name for a performance entry. The value depends on the subtype.

PerformanceEntry.entryType Read only

A string representing the type of performance metric. For example, "mark" when PerformanceMark is used.

PerformanceEntry.startTime Read only

A DOMHighResTimeStamp representing the starting time for the performance metric.

PerformanceEntry.duration Read only

A DOMHighResTimeStamp representing the duration of the performance entry.

Instance methods

PerformanceEntry.toJSON()

Returns a JSON representation of the PerformanceEntry object.

Example

Working with performance entries

The following example creates PerformanceEntry objects that are of the types PerformanceMark and PerformanceMeasure. The PerformanceMark and PerformanceMeasure subclasses inherit the duration, entryType, name, and startTime properties from PerformanceEntry and set them to their appropriate values.

js

// Place at a location in the code that starts login
performance.mark("login-started");

// Place at a location in the code that finishes login
performance.mark("login-finished");

// Measure login duration
performance.measure("login-duration", "login-started", "login-finished");

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: ["measure", "mark"] });

Specifications

Specification
Performance Timeline
# dom-performanceentry

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.