--- title: User Timing API slug: Web/API/User_Timing_API translation_of: Web/API/User_Timing_API ---
{{DefaultAPISidebar("User Timing API")}}

User Timing インターフェイスを使用すると、開発者はブラウザのパフォーマンスタイムラインの一部であるアプリケーション固有の {{domxref("DOMHighResTimeStamp","timestamps")}} を作成できます。ユーザー定義のタイミングイベントタイプには2種類あります。"mark" {{domxref("PerformanceEntry.entryType","イベントタイプ")}} と "measure" {{domxref("PerformanceEntry.entryType","イベントタイプ")}}です。

mark events are named by the application and can be set at any location in an application. measure events are also named by the application but they are placed between two marks thus they are effectively a midpoint between two marks.

This document provides an overview of the mark and measure {{domxref("PerformanceEntry.entryType","performance event types")}} including the four User Timing methods that extend the {{domxref("Performance")}} interface. For more details and example code regarding these two performance event types and the methods, see Using the User Timing API.

Performance marks

A performance mark is a named {{domxref("PerformanceEntry","performance entry")}} that is created by the application. The mark is a {{domxref("DOMHighResTimeStamp","timestamp")}} in the browser's performance timeline.

Creating a performance mark

The {{domxref("Performance.mark","performance.mark()")}} method is used to create a performance mark. The method takes one argument, the name of the mark (for example performance.mark("mark-1")).

The mark's {{domxref("PerformanceEntry","performance entry")}} will have the following property values:

Retrieving performance marks

The {{domxref("Performance")}} interface has three methods that can be used to retrieve a mark:

{{domxref("Performance.getEntries","performance.getEntries()")}}
Returns all {{domxref("PerformanceEntry","performance entries")}} in the performance timeline. Finding only mark entries requires checking each entry's {{domxref("PerformanceEntry.entryType","entryType")}} for "mark".
{{domxref("Performance.getEntriesByName","performance.getEntriesByName(name, entryType)")}}
Returns all {{domxref("PerformanceEntry","performance entries")}} in the performance timeline with the specified name and entryType, thus set entryType to "mark" to get all marks (and set name accordingly to retrieve more specific entries).
{{domxref("Performance.getEntriesByType","performance.getEntriesByType(entryType)")}}
Returns all {{domxref("PerformanceEntry","performance entries")}} in the performance timeline with the specified entryType, thus set entryType to "mark" to get all marks.

Removing performance marks

To remove a specific mark from the performance timeline, call performance.clearMarks(name) where name is the name of the mark(s) you want removed. If this method is called with no arguments, all mark type entries will be removed from the performance timeline.

Performance measures

measure events are also named by the application but they are placed between two marks thus they are effectively a midpoint between two marks.

Creating a performance measure

A measure is created by calling performance.measure(measureName, startMarkName, endMarkName) where measureName is the measure's name and startMarkName and endMarkName are the start and end names, respectively, of the marks the measure will be placed between (in the performance timeline).

The measure's {{domxref("PerformanceEntry","performance entry")}} will have the following property values:

Retrieving performance measures

The {{domxref("Performance")}} interface has three methods that can be used to retrieve a measure:

{{domxref("Performance.getEntries","performance.getEntries()")}}
Returns all {{domxref("PerformanceEntry","performance entries")}} in the performance timeline. Finding the measure entries requires checking each entry's {{domxref("PerformanceEntry.entryType","entryType")}} for "measure".
{{domxref("Performance.getEntriesByName","performance.getEntriesByName(name, entryType)")}}
Returns all {{domxref("PerformanceEntry","performance entries")}} in the performance timeline with the specified name and entryType, thus set entryType to "measure" to get all measures (and set name accordingly to retrieve more specific entries).
{{domxref("Performance.getEntriesByType","performance.getEntriesByType(entryType)")}}
Returns all {{domxref("PerformanceEntry","performance entries")}} in the performance timeline with the specified entryType, thus set entryType to "measure" to get all measures.

Removing performance measures

To remove a specific measure from the performance timeline, call performance.clearMeasures(name) where name is the name of the measure(s) you want removed. If this method is called with no arguments, all measure type entries will be removed from the performance timeline.

Interoperability

As shown in the {{domxref("Performance")}} interface's Browser Compatibility table, the User Timing methods are broadly implemented by desktop and mobile browsers (the only exceptions are  Desktop Safari and Mobile Safari, however the Safari Technology Preview 24 has support).

To test your browser's support for this API, run the perf-api-support application.

あわせて参照