The PerformanceEntry object encapsulates a single performance metric that is part of the performance timeline. A performance entry can be directly created by making a performance mark or measure (for example by calling the mark() method) at an explicit point in an application. Performance entries are also created in indirect ways such as loading a resource (such as an image).
PerformanceEntry instances will always be one of the following subtypes:
PerformanceMarkPerformanceMeasurePerformanceFrameTimingPerformanceNavigationTimingPerformanceResourceTimingPerformancePaintTiming
Properties
PerformanceEntry.nameRead only- A value that further specifies the value returned by the
PerformanceEntry.entryTypeproperty. The value of both depends on the subtype. See property page for valid values. PerformanceEntry.entryTypeRead only- A
DOMStringrepresenting the type of performance metric such as, for example, "mark". See property page for valid values. PerformanceEntry.startTimeRead only- A
DOMHighResTimeStamprepresenting the starting time for the performance metric. PerformanceEntry.durationRead only- A
DOMHighResTimeStamprepresenting the time value of the duration of the performance event.
Methods
PerformanceEntry.toJSON()- Returns a JSON representation of the
PerformanceEntryobject.
Example
The following example checks all PerformanceEntry properties to see if the browser supports them and if so, write their values to the console.
function print_PerformanceEntries() {
// Use getEntries() to get a list of all performance entries
var p = performance.getEntries();
for (var i=0; i < p.length; i++) {
console.log("PerformanceEntry[" + i + "]");
print_PerformanceEntry(p[i]);
}
}
function print_PerformanceEntry(perfEntry) {
var properties = ["name",
"entryType",
"startTime",
"duration"];
for (var i=0; i < properties.length; i++) {
// Check each property
var supported = properties[i] in perfEntry;
if (supported) {
var value = perfEntry[properties[i]];
console.log("... " + properties[i] + " = " + value);
} else {
console.log("... " + properties[i] + " is NOT supported");
}
}
}
Specifications
| Specification | Status | Comment |
|---|---|---|
| Resource Timing Level 3 | Editor's Draft | |
| Resource Timing Level 2 | Working Draft | |
| Resource Timing Level 1 | Candidate Recommendation | Adds the PerformanceResourceTiming interface and the resource value for entryType. |
| Navigation Timing Level 2 | Working Draft | |
| Navigation Timing | Recommendation | Adds the PerformanceNavigationTiming interface and the navigation value for entryType. |
| User Timing Level 2 | Working Draft | |
| User Timing | Recommendation | Adds the PerformanceMark and PerformanceMeasure interfaces as well as the mark and measure values for entryType. |
| Frame Timing | Draft | Adds the PerformanceFrameTiming interface and the frame value for entryType. |
| Performance Timeline Level 2 The definition of 'PerformanceEntry' in that specification. |
Candidate Recommendation | Added toJSON() serializer method. |
| Performance Timeline The definition of 'PerformanceEntry' in that specification. |
Recommendation | Initial definition. |
Browser compatibility
| Desktop | Mobile | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Basic support | Chrome
Full support
46
| Edge Full support Yes | Firefox Full support Yes | IE Full support Yes | Opera Full support 33 | Safari Full support 11 | WebView Android
Full support
46
| Chrome Android
Full support
46
| Edge Mobile Full support Yes | Firefox Android Full support 25 | Opera Android Full support 33 | Safari iOS Full support 11 | Samsung Internet Android ? |
| Available in workers | Chrome Full support 62 | Edge ? | Firefox Full support 60 | IE ? | Opera Full support 49 | Safari ? | WebView Android Full support 62 | Chrome Android Full support 62 | Edge Mobile ? | Firefox Android Full support 60 | Opera Android Full support 49 | Safari iOS ? | Samsung Internet Android ? |
duration | Chrome Full support Yes | Edge Full support Yes | Firefox Full support Yes | IE Full support Yes | Opera Full support Yes | Safari Full support 11 | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 25 | Opera Android Full support Yes | Safari iOS Full support 11 | Samsung Internet Android ? |
entryType | Chrome Full support Yes | Edge Full support Yes | Firefox Full support Yes | IE Full support Yes | Opera Full support Yes | Safari Full support 11 | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 25 | Opera Android Full support Yes | Safari iOS Full support 11 | Samsung Internet Android ? |
name | Chrome Full support Yes | Edge Full support Yes | Firefox Full support Yes | IE Full support Yes | Opera Full support Yes | Safari Full support 11 | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 25 | Opera Android Full support Yes | Safari iOS Full support 11 | Samsung Internet Android ? |
startTime | Chrome Full support Yes | Edge Full support Yes | Firefox Full support Yes | IE Full support Yes | Opera Full support Yes | Safari Full support 11 | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 25 | Opera Android Full support Yes | Safari iOS Full support 11 | Samsung Internet Android ? |
toJSON | Chrome Full support Yes | Edge ? | Firefox Full support Yes | IE No support No | Opera Full support Yes | Safari Full support 11 | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile ? | Firefox Android Full support 25 | Opera Android Full support Yes | Safari iOS Full support 11 | Samsung Internet Android ? |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- Requires a vendor prefix or different name for use.
- Requires a vendor prefix or different name for use.