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). This interface is exposed to Window
and Worker
.
PerformanceEntry
instances will always be one of the following subtypes:
PerformanceMark
PerformanceMeasure
PerformanceFrameTiming
PerformanceNavigationTiming
PerformanceResourceTiming
PerformancePaintTiming
PerformanceEntry.name
Read only
PerformanceEntry.entryType
property. The value of both depends on the subtype. See property page for valid values.PerformanceEntry.entryType
Read only
DOMString
representing the type of performance metric such as, for example, "mark
". See property page for valid values.PerformanceEntry.startTime
Read only
DOMHighResTimeStamp
representing the starting time for the performance metric.PerformanceEntry.duration
Read only
DOMHighResTimeStamp
representing the time value of the duration of the performance event.PerformanceEntry.toJSON()
PerformanceEntry
object.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"); } } }
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 | Editor's Draft | |
Navigation Timing | Recommendation | Adds the PerformanceNavigationTiming interface and the navigation value for entryType . |
User Timing Level 2 | Editor's Draft | |
User Timing | Recommendation | Adds the PerformanceMark and PerformanceMeasure interfaces as well as the mark and measure values for entryType . |
Frame Timing | Editor's Draft | Adds the PerformanceFrameTiming interface and the frame value for entryType . |
Performance Timeline Time Level 2 The definition of 'PerformanceEntry' in that specification. | Editor's Draft | Added toJSON() serializer method. |
Performance Timeline The definition of 'PerformanceEntry' in that specification. | Recommendation | Initial definition. |
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support. | 25 webkit 46 (unprefixed) | (Yes) | (Yes) | (Yes) |
(Yes) 33 (unprefixed) | No support |
Avaialable on workers | 62 | ? | ? | ? | 49 | ? |
toJSON() method. | (Yes) | ? | (Yes) | No support | (Yes) | No support |
Feature | Android Webview | Chrome for Android | Edge | Firefox Mobile (Gecko) | Firefox OS | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|---|
Basic support. |
(Yes) webkit 46 (unprefixed) | 25 webkit 46 (unprefixed) | (Yes) | 25.0 (25.0) | 1.2 (25.0) | 10.0 |
(Yes) 33 (unprefixed) | No support |
Avaialable on workers | 62 | 62 | ? | ? | ? | ? | 49 | ? |
toJSON() method. | (Yes) | (Yes) | ? | 25.0 (25.0) | 1.2 (25.0) | No support | (Yes) | No support |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry