This article needs a technical review. How you can help.
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).
Note: this interface is exposed to Window
and Worker
. It is extended by several interfaces including PerformanceMark
, PerformanceMeasure
, PerformanceFrameTiming
, PerformanceNavigationTiming
and PerformanceResourceTiming
.
Properties
PerformanceEntry.name
Read only- A
DOMString
representing the name of a performance entry when the metric was created. PerformanceEntry.entryType
Read only- A
DOMString
representing the type of performance metric such as "mark
". SeeentryType
for a list of valid values. PerformanceEntry.startTime
Read only- A
DOMHighResTimeStamp
representing the starting time for the performance metric. PerformanceEntry.duration
Read only- A
DOMHighResTimeStamp
representing the time value of the duration of the performance event.
Methods
PerformanceEntry.toJSON()
- A jsonizer that returns a JSON representation of the
PerformanceEntry
object.
Example
The following example checks all PerformanceEntry
properties to see if the browser supports them or not and if the browser does support the property, the property's value is written 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] + " = NOT supported"); } } }
Specifications
Specification | Status | Comment |
---|---|---|
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. |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support. | (Yes) | (Yes) | (Yes) | Not supported | Not supported |
toJSON() method. |
(Yes) | (Yes) | Not supported | Not supported | Not supported |
Feature | Android | Firefox Mobile (Gecko) | Firefox OS | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support. | (Yes) | 25.0 (25.0) | 1.2 (25.0) | 10.0 | (Yes) | Not supported |
toJSON() method. |
(Yes) | 25.0 (25.0) | 1.2 (25.0) | Not supported | (Yes) | Not supported |