--- title: Performance API slug: Web/API/Performance_API tags: - NeedsContent - Web パフォーマンス - ガイド - パフォーマンス - 概要 translation_of: Web/API/Performance_API ---
High Resolution Time 規格は、アプリケーション内でクライアント側の待ち時間測定をサポートする {{domxref("Performance")}} インターフェイスを定義しています。{{domxref("Performance")}} インターフェイスは 1000 分の 1 ミリ秒の精度であるため、高解像度と見なされます (ハードウェアまたはソフトウェアの制約を受けます)。これらのインターフェイスは、フレームレートの計算 (アニメーションでは潜在的に重要) やベンチマーク (リソースのロード時間など) を含む、さまざまな使用例をサポートしています。
Since a platform's system clock is subject to various skews (such as NTP adjustments), the interfaces support a monotonic clock i.e. a clock that is always increasing. As such, the Performance
API defines a {{domxref("DOMHighResTimeStamp")}} type rather than using the {{jsxref("Date.now","Date.now()")}} interface.
The {{domxref("DOMHighResTimeStamp")}} type, as its name implies, represents a high resolution point in time. This type is a double
and is used by the performance interfaces. The value could be a discrete point in time or the difference in time between two discrete points in time.
The unit of DOMHighResTimeStamp
is milliseconds and should be accurate to 5 µs (microseconds). However, If the browser is unable to provide a time value accurate to 5 microseconds (because, for example, due to hardware or software constraints), the browser can represent a the value as a time in milliseconds accurate to a millisecond.
The {{domxref("Performance")}}
interface has two methods. The {{domxref("Performance.now","now()")}} method returns a {{domxref("DOMHighResTimeStamp")}} whose value that depends on the {{domxref("PerformanceTiming.navigationStart","navigation start")}} and scope. If the scope is a window, the value is the time the browser context was created and if the scope is a {{domxref("Worker","worker")}}, the value is the time the worker was created.
The {{domxref("Performance.toJSON","toJSON()")}} method returns a serialization of the {{domxref("Performance")}} object, for those attributes that can be serialized.
The {{domxref("Performance")}}
interface has two properties. The {{domxref("Performance.timing","timing")}} property returns a {{domxref("PerformanceTiming")}} object containing latency-related performance information such as the start of navigation time, start and end times for redirects, start and end times for responses, etc.
The {{domxref("Performance.navigation","navigation")}}
property returns a {{domxref("PerformanceNavigation")}} object representing the type of navigation that occurs in the given browsing context, such as the page was navigated to from history, the page was navigated to by following a link, etc.
performance entries
with an entry type
of "mark
". Entries of this type are created by calling performance.mark()
to add a named DOMHighResTimeStamp
(the mark) to the browser's performance timeline.performance entries
with an entry type
of "measure
". Entries of this type are created by calling performance.measure()
to add a namedDOMHighResTimeStamp
(the measure) between two marks to the browser's performance timeline.high resolution timestamps
or metrics regarding the browser's document navigation events. 仕様書 | ステータス | コメント |
---|---|---|
{{SpecName('Highres Time')}} | {{Spec2('Highres Time')}} | Initial definition. |
{{SpecName('Highres Time Level 2')}} | {{Spec2('Highres Time Level 2')}} | Adds performance attribute on Window and WorkerGlobalScope . |
{{SpecName('Highres Time Level 3')}} | {{Spec2('Highres Time Level 3')}} | Add timeOrigin property to Performance interface. |
{{SpecName('Frame Timing')}} | {{Spec2('Frame Timing')}} | Adds PerformanceFrameTiming interface. |
{{SpecName('Navigation Timing')}} | {{Spec2('Navigation Timing')}} | Adds the PerformanceTiming and PerformanceNavigation interfaces. Adds timing and navigation properties to the Performance interface. |
{{SpecName('Navigation Timing Level 2')}} | {{Spec2('Navigation Timing Level 2')}} | Adds the PerformanceNavigationTiming interface. Obsolete's the the PerformanceTiming interface, the PerformanceNavigation interface, as well as the timing and navigation properties to the Performance interface. |
{{SpecName('Performance Timeline')}} | {{Spec2('Performance Timeline')}} | Adds the PerformanceEntry interface, the PerformanceEntryList type, as well as the getEntries() , getEntriesByType() , and getEntriesByName() methods on the Performance interface. |
{{SpecName('Performance Timeline Level 2')}} | {{Spec2('Performance Timeline Level 2')}} | Adds serializer to the PerformanceEntry interface as well as adding the PerformanceObserver interface and callback |
{{SpecName('Resource Timing')}} | {{Spec2('Resource Timing')}} | Adds the PerformanceResourceTiming interface. Adds the clearResourceTimings() method, the setResourceTimingBufferSize() method, and the onresourcetimingbufferfull event handler to the Performance interface. Also adds the Timing-Allow-Origin response header. |
{{SpecName('Resource Timing 2')}} | {{Spec2('Resource Timing 2')}} | Adds the nextHopProtocol , workerStart , transferSize , encodedBodySize , and decodedBodySize properties to the PerformanceResourceTiming interface. |
{{SpecName('Resource Timing 3')}} | {{Spec2('Resource Timing 3')}} | |
{{SpecName('User Timing')}} | {{Spec2('User Timing')}} | Adds mark() , clearMarks() , measure() and clearMeasures() methods to the Performance interface. Adds the PerformanceMark and PeformanceMeasure interfaces. |
{{SpecName('User Timing Level 2')}} | {{Spec2('User Timing Level 2')}} |
As shown in the {{domxref("Performance")}} interface's Browser Compatibility table, most of these interfaces are broadly implemented by desktop browsers.
To test your browser's support for the {{domxref("Performance")}} interface, run the perf-api-support
application.