docs.rodeo

MDN Web Docs mirror

PerformanceEntry: startTime property

{{APIRef("Performance API")}} {{AvailableInWorkers}} 

The read-only startTime property returns the first {{domxref("DOMHighResTimeStamp","timestamp", "", "no-code")}}  recorded for this {{domxref("PerformanceEntry")}} . The meaning of this property depends on the value of this entry’s {{domxref("PerformanceEntry.entryType", "entryType")}} .

Value

A {{domxref("DOMHighResTimeStamp")}}  representing the first timestamp when the {{domxref("PerformanceEntry")}}  was created.

The meaning of this property depends on the value of this performance entry’s {{domxref("PerformanceEntry.entryType","entryType")}} :

Examples

Using the startTime property

The following example shows the use of the startTime property which you can log during performance observation.

Note: The {{domxref("performance.mark()")}}  method allows you to set your own startTime, and the {{domxref("performance.measure()")}}  method allows to set the start of the measure.

performance.mark("my-mark");
performance.mark("my-other-mark", { startTime: 12.5 });

loginButton.addEventListener("click", (clickEvent) => {
  performance.measure("login-click", { start: clickEvent.timeStamp });
});

function perfObserver(list, observer) {
  list.getEntries().forEach((entry) => {
    if (entry.entryType === "mark") {
      console.log(`${entry.name}'s startTime: ${entry.startTime}`);
    }
    if (entry.entryType === "measure") {
      console.log(`${entry.name}'s duration: ${entry.duration}`);
    }
  });
}
const observer = new PerformanceObserver(perfObserver);
observer.observe({ entryTypes: ["measure", "mark"] });

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

In this article

View on MDN