PerformanceEntry

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:

Note: This feature is available in Web Workers

Properties

PerformanceEntry.name Read only

A value that further specifies the value returned by the PerformanceEntry.entryType property. The value of both depends on the subtype. See property page for valid values.

PerformanceEntry.entryType Read only

A DOMString representing the type of performance metric such as, for example, "mark". See property page for 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()

Returns a JSON representation of the PerformanceEntry object.

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

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
46
25
12
35
10
33
15
11
46
≤37
46
25
35
33
14
11
5.0
1.5
duration
28
12
35
10
15
11
≤37
28
35
14
11
1.5
entryType
28
12
35
10
15
11
≤37
28
35
14
11
1.5
name
28
12
35
10
15
11
≤37
28
35
14
11
1.5
startTime
28
12
35
10
15
11
≤37
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

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry