The PerformanceEntry object encapsulates a single performance metric that is part of the browser's performance timeline.
The Performance API offers built-in metrics which are specialized subclasses of PerformanceEntry. This includes entries for resource loading, event timing, first input delay (FID), and more.
A performance entry can also be created by calling the Performance.mark() or Performance.measure() methods at an explicit point in an application. This allows you to add your own metrics to the performance timeline.
The PerformanceEntry instances will always be one of the following subclasses:
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
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.
performance.mark("login-started");
performance.mark("login-finished");
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
Browser compatibility
|
Desktop |
Mobile |
|
Chrome |
Edge |
Firefox |
Internet Explorer |
Opera |
Safari |
WebView Android |
Chrome Android |
Firefox for Android |
Opera Android |
Safari on IOS |
Samsung Internet |
PerformanceEntry |
4625 |
12 |
35 |
10 |
3315 |
11 |
464.4 |
4625 |
35 |
3314 |
11 |
5.01.5 |
duration |
28 |
12 |
35 |
10 |
15 |
11 |
4.4 |
28 |
35 |
14 |
11 |
1.5 |
entryType |
28 |
12 |
35 |
10 |
15 |
11 |
4.4 |
28 |
35 |
14 |
11 |
1.5 |
name |
28 |
12 |
35 |
10 |
15 |
11 |
4.4 |
28 |
35 |
14 |
11 |
1.5 |
startTime |
28 |
12 |
35 |
10 |
15 |
11 |
4.4 |
28 |
35 |
14 |
11 |
1.5 |
toJSON |
45 |
16 |
35 |
No |
32 |
11 |
45 |
45 |
35 |
32 |
11 |
5.0 |
worker_support |
62 |
15 |
60 |
No |
49 |
11 |
62 |
62 |
60 |
46 |
11 |
8.0 |