PerformanceEntry

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.

PerformanceEntry 객체는 performance timeline 상의 단일 성능 수치를 캡슐화 합니다. performance entry는 응용프로그램의 특정 지점에서 performance *mark*나 *measure*를 생성함으로써 (예를 들면 mark()를 호출하는 방법으로) 직접적으로 만들어질 수 있습니다. 또는 (이미지와 같은) 리소스를 로딩하는 등의 간접적인 방법으로 생성되기도 합니다.

PerformanceEntry 인스턴스는 항상 다음 서브타입들 중 하나를 따릅니다:

참고 : 이 기능은 Web Worker에서 사용할 수 있습니다.

Properties

PerformanceEntry.name 읽기 전용

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 읽기 전용

A DOMString representing the type of performance metric such as, for example, "mark". See property page for valid values.

PerformanceEntry.startTime 읽기 전용

A DOMHighResTimeStamp representing the starting time for the performance metric.

PerformanceEntry.duration 읽기 전용

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.

js
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
Performance Timeline
# dom-performanceentry

브라우저 호환성

BCD tables only load in the browser